Jump to content

ginerjm

Members
  • Posts

    6,906
  • Joined

  • Last visited

  • Days Won

    99

Everything posted by ginerjm

  1. Trying to do some checking on my code and I have added an onclick to a button to call this function: function ShowSizes() { var btn = document.getElementById("btn"); var input_sz = btn.style.fontSize; var para = document.getElementsByTagName("p"); var p_sz = para[0].style.fontSize; /* the above don't show any values - nor do they say 'undefined' */ var div1 = document.getElementById("first_div"); var div1w=div1.offsetWidth; var div2 = document.getElementById("second_div"); alert("Checking Input size is "+input_sz + " para sz is "+p_sz + " First div W: "+div1w + " H: "+div1.offsetHeight + " 2nd div W: "+div2.offsetWidth+ " H: "+ div2.offsetHeight); } The function works but only partially. The div tag info is shown in the alert box, but the retrieval of the paragraph and my input fields with the id of 'btn' doesn't work. What am I doing wrong?
  2. Do any of them work? I have the following: var uid = window.open(url, '', 'modal=yes,dialog=yes,scrollbars=0,height=350,width=400,left='+left+', top='+top+', status=0 ,location=0, menubar=0'); The resulting window has a location bar, a status bar but thankfully, no menu bar. I'd like to get rid of everything to have it look more like a dialog box but I can't seem to. It also doesn't function "modally" altho I would like it to. I was using a showmodal before but found out from this site that it's not a good choice. But I sure would like to get these options to work. btw - I have tried to use "no" values as well.
  3. If this is off-topic, I'll understand if the mods want to remove it. I SOLVED THIS BY REMOVING THE DIV_BLACK AND BRINGINT UP THE OPACITY OF THE MAINDV - SAME EFFECT BUT WORKS ON BOTH SYSTEMS NOW. Here goes. I have a little JS code that modifies the opacity of an element on my page as part of the "onload" event. Works great in IE, not so great in Safari on my iphone. I have the following: maindv: has a background image div_black: a fullscreen div as is the above one that is all black - hiding the image behind it. div_text : has a paragraph of text displayed over the image div_imgname: a text line displayed over the bottom of the image. They are used in the following way: <div id="maindv"> <div id="div_black"> <div id="div_text"> <p> some text</p> </div> <div id="div_imgname"> <p>some text</p> </div> </div> </div> The onload event calls a workiing JS function that modifies the opacity in increments from a "start" value to an "end" value. So - one of the calls alters the black div from 100 down to 1; two other calls alter the opacity of the _text and _imgname divs from 30 to 100. The overall effect is to begin with a black screen and quickly "bring up" the image as well as the text areas. In IE it works fine. In safari the image portion works fine, but the text pieces first fade "in" but then quickly fade "out". I'm not sure if they are actually fading out, or if they are being covered by the image that is now showing thru the 'black' div that had its opacity reduced. You can see it in action at "jimginer.net" Any ideas on what Safari might be doing to make it not work? I mean - it seems to begin to work just fine, but then goes "too far" and hides the text areas by either covering them with the image or somehow reversing course and fading the text after making it appear.
  4. 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.
  5. Thanks for the references. Looks very doable! Altho I do wonder what I'm doing wrong here.
  6. 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.
  7. No - did not know that. Is there a more general purpose method or doesn't anyone else support modal windows?
  8. 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?
  9. If you could just provide the parts that are directly related to the problem, you might get more attention to your problem.
  10. 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.
  11. 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.
  12. 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.
  13. 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.
  14. Do you really think so? I didn't run across any code samples addressing this problem via 'innerhtml'. I'll try it tomorrow morning.
  15. 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?
  16. 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 */ }
  17. 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
  18. 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.
  19. 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?
  20. 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.
  21. 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.
  22. 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?
  23. 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]);
  24. 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.
  25. 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?
×
×
  • 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.