Jump to content

ginerjm

Members
  • Posts

    6,906
  • Joined

  • Last visited

  • Days Won

    99

Everything posted by ginerjm

  1. Here is the entire calling function that is not getting the returned value: function OpenLoginWin() { var url = 'myurl'; var myWindow = window.showModalDialog(url,"","dialogWidth:400px;dialogHeight:350px;center:yes;status:no;resizable:no"); alert("back in openlogin with "+myWindow); if (myWindow='' || !myWindow) { document.getElementById('uiddiv').innerHTML = ""; } else { document.getElementById('uiddiv').innerHTML = "New User is "+myWindow; } } Here is the function that is returning to the above code: function CloseMe(uid) { window.returnValue=uid; alert("in closeme with "+uid); self.close(); return; } As you can see I didn't leave much out. The alert in 'closeme' is showing the correct value to be returned. The alert in the calling function is showing a value of 'undefined'after the return occurs. I think perhaps that I am not utilizing the 'returnValue' statement correctly, but that was how two examples I found were using it.
  2. Thanks for the references. Looks very doable! Altho I do wonder what I'm doing wrong here.
  3. ok - I found an example of using returnValue. Added the code and here's what happens. my dialog alert shows that I have a valid value to return to the caller. my caller js routine shows that the value received is correct Yet - my use of the following statement: var myWindow = window.showModalDialog(url,"","dialogWidth:400px;dialogHeight:350px;center:yes;status:no;resizable:no"); document.getElementById('uiddiv').innerHTML = "New User is "+myWindow; yields the following: New User is false What am I doing wrong now? for those who need refreshing here is my code: caller has var myWindow = window.showModalDialog(url,"","dialogWidth:400px;dialogHeight:350px;center:yes;status:no;resizable:no"); alert("back in openlogin with "+myWindow); if (myWindow='' || !myWindow) { document.getElementById('uiddiv').innerHTML = ""; } else { document.getElementById('uiddiv').innerHTML = "New User is "+myWindow; } And my called window's code is function CloseMe(uid) { window.returnValue=uid; alert("in closeme with "+uid); self.close(); return; } All of my alerts show what I expect them to. It's just the very last statement in my caller that yields the unexpected.
  4. No - did not know that. Is there a more general purpose method or doesn't anyone else support modal windows?
  5. actually that piece of the snippet was out-dated. Just an experiment from some sample code I found. Which didn't work either. As for your suggestion can you give me a sample?
  6. If you could just provide the parts that are directly related to the problem, you might get more attention to your problem.
  7. ok - I've been using a modaldialogbox to handle a login process. It all works fine, but I'm trying to add a returned string value and want to use it in the calling script's function that triggered the dialog. This is my calling code snippet which is in a js function myWindow = window.showModalDialog(....); alert("back in caller with a value "+myWindow); This is my code from the called dialog box's return function: function CloseMe(uid) { alert("about to pass back "+uid); self.close(); return ('uid'); } The alert in the return shows a valid value for "uid", so I'm expecting it to be returned to the caller and be in "myWindow", but the alert in calling code shows the returned value as undefined. Took me a while to get this much of it working - I even have the follow-up code to handle the returned value ready to go, so what am I missing at this point? I tried putting my return var in the "close()" line but that didn't work either.
  8. SOLVED. Stupid javascript syntax! My code used "getElementByID" which not one of the over a dozen viewers of this post picked up on as being mis-typed. Stupd Javascript syntax. Why did the creators of this handy language make it so unique? I've been programming since the 70's and have never encountered a language (other than LISP which those who know it hate for its own syntax problems) that had such strict syntactical rules.
  9. I've been trying many things and here is a slight change in the problem I think. Here is my js code: var div = document.getElementByID('maindv'); if (w > 500) { div.style.backgroundImage ="url('images/SunriseatThacher_IMG_3113_300x460.jpg')"; } My error message (object doesn't support this property or method) is on the first line of code. Here is the rest of my html <body bgcolor="#000000" onload="FadeOpacity('div_black', 80, 1, 3000, 15),FadeOpacity('div_text', 5, 100, 5500, 10),FadeOpacity('div_imgname', 5, 50, 5500, 10),document.thisform.btn.focus()"> <div id="maindv"> <div id="div_black"> <div id="div_text"> <form name="thisform" method="POST" action="index.php"> <p id="p1">Welcome to my site. As this new effort of mine grows, I will be providing access to some tools that I find useful and that others may enjoy; photographs that I have taken from around my area, my vacations and other items of interest, as well as whatever crosses my mind and makes it to the web.</p> <p id="p_italic">I hope you enjoy.</p> <br> <center> <input id="btn_italic" name="btn" type="submit" value="Enter >>"> </center> <input name="chg" type="button" onclick="SetSizeforScreen()" value="Change Bkgrnd"> </form> </div> <div id="div_imgname"> <p>Sunrise in Thacher Park</p> </div> </div> </div> </body> A simple page with 3 divs, the first one being the one I'm trying to modify. Note I have used the correct spelling of my id tag and there is no duplication of the name with any function or something like that. All my research for js tips and tricks tell me I am doing the right thing, yet IE is telling me it's wrong.
  10. ok - here's what I tried: document.getElementById('div_img').innerHTML = 'background-image:url(images/SunriseatThacher_IMG_3113_300x460.jpg);'; the result? I now see the string on my screen.
  11. Do you really think so? I didn't run across any code samples addressing this problem via 'innerhtml'. I'll try it tomorrow morning.
  12. Trying to use a different sized image when a user comes in from an iphone instead of a regular computer screen. Have a secondary image uploaded, have the ability to check the screen size, and have a function call in my body tag's onload event. BUT - I'm getting the message "object doesn't support this property or method" when the js code executes. The offending line is: document.getElementByID('div_img').style.backgroundImage ='url(images/SunriseatThacher_IMG_3113_300x460.jpg)'; I've read everything I can find on the net and I dont' see what is wrong. I've tried different combos of quotes on the url portion and they didn't make a difference. The id name is correct - matches the div that I'm trying to alter. I think my capitalization is correct. Anyone?
  13. solved my own problem. It seems that the mere fact that I have opened up a modal dialog (showmodaldialog), my executing function is waiting upon the dialog's return. Tada!! I simply added a line to refresh my 'main' window right after the call - which executes only when the dialog returns. Here is my function in my main window: function OpenLoginWin() { var url = 'http://voorheesvillefd.org/vfdlogin1.php'; myWindow = window.showModalDialog(url,"","dialogWidth:430px;dialogHeight:390px;center:yes;status:no;resizable:no"); window.location.reload(); /* force a reload of this page to show the logged in name at the top */ }
  14. it's just a js function that I found on the net. works great. Here's a link to it. http://javascript.gakaa.com/window-showmodaldialog-4-0-5-.aspx
  15. Thanks for the feedback people, but I have to say I don't understand either reply. thorpe - if showmodaldialog is not a built-in function, then what the h. is it? hemo-ali - thank you for the code you posted, but what the heck is it doing? Doesn't seem to address my problem. A brief re-telling of my needs: form has a button that opens up a dialog box wherein the user does something that affects the calling form. User closes the dialog and I want the calling form to refresh itself automatically so that the user sees confirmation of the changes he/she made by using the dialog box.
  16. I figured out how to use a showmodaldialog call to open up a 'login' window. It gets called from the current form, pops up on top of the current form, does the login and then closes itself, leaving control back with the current form. What I WANT to do is force the current form to do a refresh using another js call, but how can I trigger that? Is there some kind of "wait" mechanism that I can set when I do the showmodaldialog call so that I can then execute the refresh function and then turn control back to the user?
  17. ok - found a post that made me notice that the button should be changed from a Submit to a Button type and voila! a js function using location.href = "myurl" works just perfect.
  18. I want my Cancel button to send me back to whence I came from. I've researched and found tons of postings saying to do history.go(-1), history.go(), window.location.reload('myurl') and other things - all of which didn't do it. Back is good, but even better would be the ability to provide a url to execute. I want to tie this function(?) to the onclick event of my Cancel button.
  19. Never used it before and after much trial and error and several bad code examples from you-know-where, here I am. Want to display a little countdown on my re-direct page. Set up a counter function and a display-it function. Counter function is called by "onload="CountDown()" in the "body" tag of my html Here are the functions. var sttime = 5; function myTimer() { document.getElementById('timerbox').innerHTML=sttime+" seconds to go"; sttime = sttime - 1; return; } function CountDown(tm_val) { myTimer(); while (sttime >0) { var t=window.setTimeout(myTimer,1000); } return; } Note that the var 'sttime' is global and is used in both functions. Note also that 'timerbox' is an h2 element in my webpage. The goal is to display the initial value (which works), then to display a reduced value every second after that until the value becomes 0. What happens is I see a 5 displayed (the starting point) and then a 0 on the next display, and then nothing changes. Actually I think I'm hanging up my server since response dies after that. Are my functions valid?
  20. With the help of this forum I have learned to use json-encode to take the results of a mysql query in php and build a JS array to use in a JS function on my page to supply looked up names in response to a entered number value. Works great! The code that displays the results is the same code (same exact lines) thta gets used on a copule of different screens for different purpose. Here's the problem. I created a new screen layout using the code by adding some line breaks basically using html to re-arrange my input screen to make a better layout for printing. That's all. But - on 2 of my screens names stored in my table such as O'Meara show up just fine, on the 3rd (new) screen this name shows up as O\'Meara. Thinking that I probably needed to add the slash to the database and then use PHP "stripslashes" to remove it when I retrieved it, I added that to my query results process. It still shows up with the slash. In fact, I played around and added an apostrophe to another entry on the table and re-ran the code and now I get a \ in both names, but only on the one screen. So - I went back and removed the slash from the one table entry that I put it in and it still shows up on this one screen with a slash. I am absolutely positive that the same line of html/php is producing the output for all 3 screens, so what could be doing this in one situation only? I've looked at the html file that is being displayed and there is no embedded \ character in the guy's name, EXCEPT in the place where the html is displaying it in the value= parameter. The JS array does not have a \ character in hte guy's array element. Some code pieces below this is how I retrieve the data from the table and build the php array: $golfers["$gnum"] = stripslashes($row['golfer']); this is how I create the js array: var jsgolfers = <?php echo json_encode($golfers); ?>; this is how I retrieve the array element and place in into the html input tag (name="pickname"+a number in 'str') document.getElementById("pickname"+str).value = stripslashes(jsgolfers[choice]);
  21. you da man! That was the simplest fix I've ever been given in all my years on many different forums for many different subjects. Thank you very much.
  22. ok - I have an assoc php array that works just like I want it to. The indices of it are not 0.....n but instead the assigned numbers I have in my sql table. I use this to build my js array var jsgolfers = ["<?php echo implode("\",\"",$golfers); ?>"]; which builds just a normal enumerated array, even tho the indices of $golfers are not enumerated. So - while php tells me that $ar["4"] (which is actually the 2nd element) is "Tiger", JS says it is a couple more cells down the line and shows "Phil". Any way of managing this in JS?
  23. After much research and some great tips, I have managed to move a php generated query/array to a js array. My code works great and all but what I need to do now is to make the js array an "associated" one. Ex. my php query produces a result of 1 Tiger 4 Phil 3 Nick I can make an assoc array in php that would look like: $ar["1"] = "Tiger" $ar["4"] = "Phil" instead of $ar[0] = "Tiger" $ar[1] = "Phil" How can I get the assoc php array format into a js array so that I can do a look up on a value of "4" and come up with "Phil" instead of undefined? Does JS even have associative arrays?
  24. MUCH better. Thanks!
  25. Lifted from examples on "helpful" web pages. I had to modify that just to get a response out of it - which took me hours!
×
×
  • 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.