Jump to content

ginerjm

Members
  • Posts

    6,906
  • Joined

  • Last visited

  • Days Won

    99

Everything posted by ginerjm

  1. This is the js that is called from the submit buttons. function handleLogin(btn) { var uid = document.getElementById('uid').value; if (uid=='') { alert("You must enter a name"); return false; } var pswd = document.getElementById('pswd').value; if (pswd=='') { alert("You must provide a password"); return false; } /* Now do an xmlhttprequest to validate the credentials Returned value will be similar to above returned values */ url="http://jimginer.net/bowling_login.php?uid="+uid+"&pswd="+pswd+"&btn="+btn; alert("in js_login_test.php calling bowling_login via xml"); /* create a var to do the process */ var myreq = new XMLHttpRequest(); myreq.open("GET", url, true); myreq.send(null); myreq.onreadystatechange = function() { if (myreq.readyState == 4) { if (myreq.status == 200) { /* handle the data returned from the above GET request */ allText = myreq.responseText; rtnval = handleResponse(allText); if (rtnval) { alert("returniing to button with true"); return true; } else { alert("returniing to button with false"); return false; } } else { alert("Error processing login attempt - message follows: "+myreq.statusText); return false } } else { } } } The buttons that call this function look like: <input type="submit" name="btn" value="Log In" onclick="return handleLogin('LogIn')"> <input type="submit" name="btn" value="Register" onclick="return handleLogin('Register')"> As you can see my alerts say one thing, but my results are different.
  2. Nice idea, but I need to know which 'submit' button was clicked.
  3. OK - I've done this before, but I'm having a problem now. I have a form with a submit button declared as <input type="submit" name="btn" value="Log In" onclick="return handleLogin('LogIn')"> The onclick routine - after much debugging - is working and at the end of its processing I have this: allText = myreq.responseText; rtnval = handleResponse(allText); if (rtnval) { alert("returniing to button with true"); return true; } else { alert("returniing to button with false"); return false; } The alerts are displaying that the return value is "false", yet my original button performs the submit, which I know because the script in the form's action is being called - when it shouldn't be. I hope I've provided enough info - does anyone see what I'm not?
  4. For anyone following my dilemma - here's my solution (still in the works, but designed) My main menu link has an onclick event on it that gets a boolean answer from the js code - this will then either call my appl's script, or stay right there on the menu (false = no submit). The onclick js function will open a dialog box (a hidden div actually) containing my login form fields. The form will receive the info from the user and on the 'log in' button another onclick will call a js function that grabs the input, makes an httprequest call to a php script that validates the user's entries and returns true or false (with a message). This is the result that is passed all the way back to the original menu onclick.
  5. I'm starting to think along those lines now. But - I don't have a handle on how to interact with the user using js. I can write an httprequest to validate the input, but how does one get that input without having a new sript?
  6. Lemmin, I think you have the idea. Yes - the login/popup window does the verification/authentication and then decides if the user should continue on or re-try his login. My trouble is getting the "continue on" to appear in the right window. That's my dilemma. With IE I've not had good success addressing the parent window/script. From some things I've researched, I should be able to pass something back from my window.open (js) but that never works for me in IE. Do you have some code I could see that works? Or did you have something else in mind for this process?
  7. Very simple subject but not the way I want to do it perhaps. Basically, I have a php-generated full-screen menu on screen. One link on it calls a js func to open up a small window on top and call a php script to handle the login process inside this popup. Once the user is validated (by the php script in that popup), I want to continue on to a full-size window, closing the login window behind me. I'd really like to re-use the original php menu's window, but if I have to open up a new window on top of it, so be it. Of course, if the logon fails, I'd like to return an error message to the popup window and let the user try again. So - how does one do this? Right now, my menu opens the popup just fine and the called url functions perfectly - I just can't get the next script top run in the appropriate window.
  8. After all my struggles, putting into a small php module and using the url parm solved all my issues. Thanks for the help Adam, and the final suggestion.
  9. This started out as such a simple task I thought the JS way would be easier. Now that it's turned out to be more of a bear, I kinda wonder what I'm doing wrong. But you're right - maybe it's time to punt if you don't see the problem.
  10. Ya know - I read something about () just this morning, but didn't make the connection to my own circumstances. Doh! So - now my timeout works. But - the setFocus doesn't. Here's that specific code: myWindow.document.writeln( "<script type='text/javascript'>" ); myWindow.document.writeln( "function setFocus()" ); myWindow.document.writeln( "{document.getElementById('btn').focus();" ); myWindow.document.writeln( "alert('should have setFocus');" ); myWindow.document.writeln( "return;}" ); myWindow.document.writeln( "</" + "script>" ); The Alert happens, but the actually setting of focus on my button doesn't happen. And just so you can see it here is the button definition: myWindow.document.writeln("<form name='thisform' id='thisform'>"); myWindow.document.writeln( "<center><input type='button' name='btn' id='btn' value='Close' onclick='window.close()' tabindex=1></center>" ); myWindow.document.writeln( "</form>" ); This is a lot tougher than I thought it would be.
  11. Now that the ending Script tag works, I'm struggling to get the function to work properly. The layout is - my main window is opening up a popup that will show some info to the user. I define my popup, open it, populate it with the data, include a button to close the window, and the last piece is to set the focus on the button. There's the problem and here's the entire code: function openAddrWin(nm,idx) { var url =''; var width = 230; var height = 190; var left = parseInt((screen.availWidth/2) - (width/2)); var top = parseInt((screen.availHeight/2) - (height/2)); var addr_parts = Addresses[idx].split("|"); var windowFeatures = "width=" + width + ",height=" + height + ",left=" + left + ",top=" + top + "screenX=" + left + ",screenY=" + top; windowFeatures += ",status=yes,location=no,menubar=yes,directories=no,resizable=yes,toolbar=no,titlebar=no,scrollbars=no"; var myWindow = window.open(url, "subWind", windowFeatures); myWindow.document.write( "<html><head>" ); myWindow.document.write( "<style type='text/css'>" ); myWindow.document.write( "#div1 {float:left;position:relative;margin-left:20px;}" ); myWindow.document.write( "</style>" ); myWindow.document.write( "<script type='text/javascript'>" ); myWindow.document.write( "function setFocus()" ); myWindow.document.write( "{alert('in setFocus');document.getElementById('btn').focus();return;}" ); myWindow.document.write( "</" + "script>" ); myWindow.document.write( "</head>" ); myWindow.document.write( "<body bgcolor='#c0c0c0'>" ); myWindow.document.write( "<div id='div1'>" ); myWindow.document.write( "<center>Mailing Address for: </center><br>" ); myWindow.document.write( nm + "<br>" ); myWindow.document.write( addr_parts[0] + "<br>" ); if (addr_parts[1] != '') myWindow.document.write( addr_parts[1] + "<br>" ); myWindow.document.write(addr_parts[2]+", " + addr_parts[3] + " " + addr_parts[4] + "<br>" ); myWindow.document.write("<form name='thisform'>"); myWindow.document.write( "<center><input type='button' name='btn' id='btn' value='Close' onclick='window.close()'></center>" ); myWindow.document.write( "</form>" ); myWindow.document.write( "</div></body></html>" ); setTimeout(myWindow.setFocus(),2000); } The very last line (settimeout) is supposed to wait 2 seconds and then execute a function that will place the focus on my 'Close' button in the new popup. I'm using setTimeout because I figure an onload won't work since there is no button at the time the popup's load finishes, so I thought that by waiting a bit and then calling a function to set the focus would be the trick. The problem is that the settimout doesn't wait for 2 seconds - it executes immediately. I've tried setInterval as well - no luck. Any ideas?
  12. I'm guessing that the 'value' isn't posted until the value "changes". YOu didn't say that you wanted this calc. to take place as you enter digits. Doesn't make a lot of sense. In any case, you're going to have to handle keys that are not digits, as well as backspaces, deletes, escapes as well as 0-9.
  13. You want US to go thru the LightBox code? No thanks.
  14. add an onchange=someFunction() to your input field; in the function, calculate myNewValue (product, not sum!) and then post it to the field that you want it in with something like document.getElementById(yourSumFld) = myNewValue. Try it and then come back with your code and questions.
  15. I'm opening up a popup window from my php code using a js function. Then I try to write some info and a short js function to the popup. Been playing with this for about 3 hours. IE gives me an error message "unterminated string constant" when I include the following lines within the rest of my js "write" statements: myWindow.document.write( "<script type='text/javascript'>" ); myWindow.document.write( "function setFocus() {" ); myWindow.document.write( "document.getElementById('btn').focus();}" ); myWindow.document.write( "</script>" ); Without this code my js function is error free and works. With it IE says that line xxx has an unterminated string. Line xxx happens to be (every time!) the last line with the "</script>" piece. Take it out and I don't get an error but my end product doesn't work since the lack of the closing script tag ruins the whole function's usefulness. What is wrong with that simple write statement?
  16. A new day - new work being tried. I've added the following to my code and am displaying the function that is failing me below. First - a little function that really doesn't help me, but adds to the paradox of things. function checkOpener() { console.log("entering checkOpener"); if (window.opener == null) { alert("There is no window.opener available"); console.log("exiting checkOpener with false"); return false; } else { console.log("exiting checkOpener with true"); return true; } } This function returns true every time, I guess 'window.opener' is present, but the properties under it aren't. function ShowWelcome(uid) { console.log("entered showwelcome"); if (!checkOpener()) return; console.log("Attempting first uidobj"); uidobj = window.opener.getElementById('uid'); console.log("uidobj at step2 is "+uidobj); uidobj.innerHTML = "Welcome "+uid; console.log("leaving showwelcome"); return; } I never get the console message "... at step 2...". Adding the displays to the console log helps to confirm that the window.opener is just plain not functioning when running on an iPad. Additionally, the following code in my "close" function also fails: function CloseMe() { console.log("Entering closeme function"); if (checkOpener()) { console.log("in closeme href is "+window.opener.location.href); window.opener.location.href = window.opener.location.href; } self.close(); } This code is supposed to refresh the calling window (in order to pick up some newly available info now that the user is logged in. It works fine on my iphone, my IE and Safari on the PC. On the ipad however, it shows that href is undefined in the console, and the close actually sends me to a url of "...../undefined" due to the reloading of the href property here. Hope this intrigues and/or helps someone to give me an idea. There doesn't seem to be much about iPads and this problem available to search on.
  17. I have a form that opens up a login window Once the user logs in correctly, I run some js to modify an element on my main window (the caller) and then I close my login window (the child). This script and the js work just perfectly on my IE tests, my Safari test on a PC and my iphone 4 but my ipad has a problem with my js. I've tried to find how to do this and have used two diff methods to try and get around the problem, but I'm getting nowhere. I was using window.opener.document.getElementById('idname').innerHTML="something"; in the child window. Then I read about this method logwin = window.open(......); logwin.idxpage = self; in my calling window and then this: ... idxpage.getElementById('idname'].innerHTML = "something"; in the child window, but this fails telling me that 'undefined is not an object'. I also tried: self.idxpage.getElementById('idname').innerHTML = "something"; in the child, but that doesn't get recognized either. I've been re-reading my code for an hour and I've reread the articles I used over and over. Again - this works great on my IE and Safari and iphone - just not the ipad.
  18. Ok - been doing some reading. Some older posts found with G suggest that some elements are not re-writable with js. Table is one of them. So, if that is true, then I'll just have to alter my approach a bit. Hope this helps the next person.
  19. The idea looks simple enough - so consequently I'm having a problem. This is a bit of html I have in a table that I generate via PHP that I want to modify on-the-fly with JS: echo "<tr class='pdata' id='row$i'><td>$k</td><td><input type='text' id='plyr$i' value='$v' size=3 maxlength=3 onchange='HandleSeedAssignment()'></td></tr>"; My JS function looks like this: function ShowPlyrs() { pobjs = document.getElementById('plyrtbl').getElementsByTagName("tr"); nobjs = pobjs.length; alert("found "+nobjs+" tr elements"); for (i=0;i<nobjs;i++) { pobj = pobjs[i]; if (pobj['className'] =='pdata') { document.getElementById(pobj.id).innerHTML = "<td>xyz</td><td>abc</td>"; } } return; } It all works EXCEPT the last line that is supposed to re-write the <tr> element. Running IE I'm getting "Unknown runtime error on line ###" which is the line putting out the new innerHTML. I've tried specifying my destination object a couple of ways. Originally I tried pobj.innerHTML = "<td>xyz</td><td>abc</td>"; but that didn't work either. Any ideas? I'm sure it's simple.
  20. Here is what finally worked. in my html i have a button that has ... onclick="confirmDeleteEvent(this.form)".... in my js function I do this: function confirmDeleteEvent(thisfrm) { var ans = confirm("You will delete this event and any associated partner data. OK?"); if (ans) thisfrm.submit(); else return; } Don't know what the resonse about objects being out of scope means. But this code definitely works!
  21. Solved this from a posting I found. var evts = TMS_evt_names.length; var globalfld = null; function isValidEvent(obj) { var choice = obj.value.toUpperCase(); if (choice=='') return true; var k = evts; while (k--) if (TMS_evt_names[k] === choice) return true; alert("' "+choice+" ' is not a valid Event code."); obj.value=''; setFocus(obj); return false; } function setFocus(elm) { globalfld = elm; setTimeout("globalfld.focus();globalfld.select()",100); } This takes the value of the incoming object (called via "onclick='isValidEvent(this)'" in my html and checks if the value is in my array. If not, it erases it from the screen and repositions the cursor back on that field.
  22. I have a button that has the following: onclick="confirmDeleteEvent($i)" in my php code. My JS code is: function confirmDeleteEvent(i) { frmname = 'entform'+i; alert("in confirmdelete with "+frmname); var ans = confirm("You will delete this event and any associated partner data. OK?"); if (ans) { document.getElementById(frmname).submit(); } return; } My alerts tell me that I have values in the JS that make sense to me. Yet I can't get it to accept the submit call. Message is "object doesn't support this property or method". What am I doing wrong? I have tried many different ways (that I found on the net) which also don't work. Amazing how many tips are out there that are just plain wrong.
  23. Interesting response. Thanks for pointing it out. Wonder why that came up in my google search for findgin something in an array?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.