-
Posts
6,906 -
Joined
-
Last visited
-
Days Won
99
Everything posted by ginerjm
-
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?
-
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?
-
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.
-
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.
-
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.
-
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.
-
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?
-
No Shit!! Thanks for the heads-up.
-
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.
-
You want US to go thru the LightBox code? No thanks.
-
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.
-
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?
-
trying to modify an element on a caller form from a child window.
ginerjm replied to ginerjm's topic in Javascript Help
Except - modal isn't cross-browser compatible. -
trying to modify an element on a caller form from a child window.
ginerjm replied to ginerjm's topic in Javascript Help
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. -
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.
-
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.
-
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.
-
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!
-
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.
-
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.
-
Interesting response. Thanks for pointing it out. Wonder why that came up in my google search for findgin something in an array?
-
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.
-
Solved . See my other post "onclick and submit - sequence"
-
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.
-
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?