Jump to content

ginerjm

Members
  • Posts

    6,906
  • Joined

  • Last visited

  • Days Won

    99

Everything posted by ginerjm

  1. 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.
  2. 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.
  3. 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?
  4. 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.
  5. You want US to go thru the LightBox code? No thanks.
  6. 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.
  7. 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?
  8. 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.
  9. 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.
  10. 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.
  11. 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.
  12. 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!
  13. 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.
  14. 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.
  15. Interesting response. Thanks for pointing it out. Wonder why that came up in my google search for findgin something in an array?
  16. From a little hunting around I found this (no, not from W3): var TMS_evt_names = ["<?php echo join("\", \"", $TMS_evt_names); ?>"]; function chkEvent(i) { choice = document.getElementById("evt"+i).value.toUpperCase(); alert("in chkevent with "+choice); idx = TMS_evt_names.indexOf(choice); if (idx < 0) { alert("invalid event"); return false; } else { alert("found "+TMS_evt_names[choice]); return true; } } The array in the first line is being built, since I can see it in my browser. My problem is - when I run it and the function is called, IE tells me the the line with the indexof reference "doesn't support this property of method". I do note that in most examples using indexOf that the arg is a string constant, rather than a variable. How do I get the variable to work in this instance. I already tried using "indexOf(choice.value)" but that didn't work either.
  17. Solved . See my other post "onclick and submit - sequence"
  18. Not an Answer - but problem solved. Since my js submit can't send the text of the submit button that triggered it and therefore my php script didn't know where the submit was coming from I did this. Since the form that was involved had field names unique to that portion of my webpage, I just checked for the existence of one of those names and set the button field name=the text that is in the value= parm. That allowed my script to think that it was coming from the appropriate form and my work can continue. Interestingly enough - the problem wherein an html field that I modified in the JS function prior to the submit now shows up correctly in the PHP script, whereas when I was trying to let the submit button trigger the submit event after the onclick was complete, I was losing the value of that modified field.
  19. From my reading I believe that the onclick event that calls my js function happens before the button (submit) that triggered it actually triggers the php script designated in the form tag. Here's my problem. The JS function that is called by the onclick does some verification that may end up altering the value of a field in the form being submitted. What I'm seeing is that the change to the field is NOT getting picked up by the POST in the php script triggered by the submit button. Is that normal? My debugging tells me that the modification to the field takes place in the js function, and I can even see the change on my screen. But - when the script executes my echos tell me that the value didn't get picked up. It seems that the POST vars are collected as soon as I click on the form's submit button, then the onclick JS function does its thing, and then finally the php script gets called, using the POST vars that had already been created. Is this true?
  20. Finally solved. Once I added my missing closing form tag my JS submit now runs the script that the old 'submit' button used to do. I now consider this problem solved. See my next post for how to handle the value of the submit button which I no longer have available in my php script since JS did the submit.
  21. Normally, I submit forms with a submit button and check the value of that button in my script to see how to handle it. I'm learning how to use a type=button instead and having my js validation function do the submit. Now I discover that my script is not getting the value of the button object (naturally) so my script doesn't know what to do. How does one pass to the PHP script the button name from a JS function? My form is usually submitted with a POST.
  22. Somewhat solved!! I left out a closing form tag for the form preceding my problem forms. Now I'm at least getting the submit to happen - although I still have some html errors occurring now.
  23. Well, you've seen the submit code. Here's the form: function DisplayAnEvent($e,$cntr) { global $php_path,$key,$hide; echo "<tr>".PHP_EOL; echo "<td><form id='entform$cntr' name='entform$cntr' method='POST' action='" . $php_path . 'tmsentry.php' . ">"; echo "<input type='$hide' class='ent_hide' name='eid' value='$key' size=1 tabindex=-1>"; echo "<input type='$hide' class='ent_hide' name='origevt' value='$e->event' size=1 tabindex=-1></td>"; $code=<<<heredocs <td><input class="ent" type="text" id="evt$cntr" name="evt" value="$e->event" maxlength=5 size=5 onchange="PostChgMsg('Event')"></td> <td><input type='$hide' class='ent_hide' id='pid$cntr' name='pid' value='$e->partner_id' size=1 tabindex=-1></td> <td><input type='$hide' class='ent_hide' id = 'orig_pln$cntr' name='orig_pln' value='$e->part_ln' size=1 tabindex=-1></td> <td><input class="ent" type="text" id = 'p_ln$cntr' name="p_ln" value="$e->part_ln" maxlength=25 size=29 onchange="PostChgMsg('Event')"></td> <td><input type='$hide' class='ent_hide' id='orig_pfn$cntr' name='orig_pfn' value='$e->part_fn' size=1 tabindex=-1></td> <td><input class="ent" type="text" id='p_fn$cntr' name="p_fn" value="$e->part_fn" maxlength=18 size=21 onchange="PostChgMsg('Event')"> </td> <td><input type='$hide' class='ent_hide' id='orig_pmi$cntr' name='orig_pmi' value='$e->part_mi' size=1 tabindex=-1></td> <td><input class="ent" type="text" id='p_mi$cntr' name="p_mi" value="$e->part_mi" maxlength=1 size=2 onchange="PostChgMsg('Event')"> </td> <td><input class="ent" type="text" id="sttm$cntr" name="sttm" value="$e->starttime" maxlength=12 size=12 onchange="PostChgMsg('Event')"> </td> <td><input class="ent" type="text" id="drpos$cntr" name="drpos" value="$e->drawpos" maxlength=2 size=3 onchange="PostChgMsg('Event')"> </td> <td><input type='button' class='btn_sm' name='btn' onclick='return ValidateEvent("$cntr","entform$cntr")' value='<- Update this Event'></td> </tr></form> heredocs; echo $code; } Enjoy!
×
×
  • 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.