JavaScript - Popup "dont' Show Again" Option
I have created a page where everytime the page loads a popup window opens and diplays a message. This is done through javascripting. After the message is read the reader can close the window. The popup page is an actual html page and not a dialog box. This is fine except, everytime the visitor comes back to that page the window pops up. Is there a way to hve it where I can insert a link or button that says "Don't show message again" . That way it will pop up the first time but if the reader clicks that "Don't show message again" it will not appear again. Maybe set some sort of cookie. HELP ME PLEASE
Similar TutorialsIs there a way to remove (not disable and not delete) an option in a "select" list, and restore it later when needed? I have a form with many huge lists ("select" with many "options") that depend on eachother. I am dynamically updating the form through server, and wish to update the list values by sending a mask string. This way I could remove and restore the options without the need to pass the whole list again. I tried many ways but none work: * option.diabled="disabled" is not good because it is still shown * option.style.visibility='hidden' is not good because it is still taking a row * option=null is not good because I will not be able to restore it I need a method similar to the following one for remove/add fields in a form: remove: <field>.style.display='none'; resto <field>.style.display=block'; Thank you!!! Hi , Kindly help I have to handle the browser RED X close button in the window. The problem is that its not saving the data. before submitting/saving the data it executes the window.close() I put settime out and form on submit conditionalyy put even its not saving the data But window is closing. how can we sequentiate the save + window.close() im copying the code below. ============ window.onbeforeunload = function() { if (window.event.clientY < 0 && (window.event.clientX > (document.documentElement.clientWidth - 5) || window.event.clientX < 15)) { editedCheck(); document.BuildRequestForm.buttonClicked.value="REDX"; if( document.BuildRequestForm.measdatachanged.value=="false") { setVarZero(); fn_Close(); } else { if(confirm('Do you want to save the changes?')) { elmtForm.onsubmit = fn_Close; //document.BuildRequestForm.onsubmit=fn_Close; //setVarZero() saveMeasurement(); setTimeout('setVarZero()',1000); //window.setTimeout(function() { window.close();}, 1000); //window.setTimeout(function() { fn_Close();}, 1000); //fn_Close(); //return true; } else { return "If you want to close the window click - Leave Page";} } } } ============= browser close RED X button+ popup OK Cancel "save or not" +OK Does anyone have a sizeable popup that will work in google chrome?? I have tried several scripts for this with no success, they all open full page.. Here is an example of what I am looking for... The problem with this is it opens a new page plus a full page popup Code: <script type="text/javascript"> <!-- function popup(url) { var is_chrome; var width = 1020; var height = 600; var left = (screen.width - width)/2; var top = (screen.height - height)/2; var params = 'width='+width+', height='+height; params += ', top='+top+', left='+left; params += ', directories=no'; params += ', location=no'; params += ', menubar=no'; params += ', resizable=yes'; params += ', scrollbars=yes'; params += ', status=no'; params += ', toolbar=no'; newwin=window.open(url,'windowname5', params); is_chrome= navigator.userAgent.toLowerCase().indexOf('chrome') > -1; if (is_chrome) {newwindow.parent.blur();} if (window.focus) {newwin.focus()} return false; } // --> </script> To open I am using Code: onclick=popup(mypage.php?id=".$row->id." I found this code sample that when a user clicks somewhere on the image, then an "X" will appear. I would like to have the "X"s remain visible even when the user clicks on a different area of the image. As you can imagine, a user clicks clicks clicks then there are "X"s everywhere. How do I do this? Do I need to create more "div" tags with the mouse click locations? <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Mouse position</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta http-equiv="Content-Style-Type" content="text/css"> <meta http-equiv="Content-Script-Type" content="text/javascript"> <script language="JavaScript" type="text/JavaScript"> var posx; var posy; function getMouse(e){ posx=0;posy=0; var ev=(!e)?window.event:e;//IE:Moz if (ev.pageX){//Moz posx=ev.pageX+window.pageXOffset; posy=ev.pageY+window.pageYOffset; } else if(ev.clientX){//IE posx=ev.clientX+document.body.scrollLeft; posy=ev.clientY+document.body.scrollTop; } else{return false}//old browsers } function showP(){ document.getElementById("div2").style.visibility="visible"; document.getElementById("div2").style.top =(posy-10)+'px'; document.getElementById("div2").style.left=(posx-6)+'px'; } </script> <style type="text/css"> .div1 {position:absolute;top:100px;left:100px;visibility:visible;z-index:5} .div2 {position:absolute;top:0px;left:0px;visibility:hidden;z-index:1;color:black;} .div3 {position:absolute;visibility:hidden;z-index:10;font-family:monospace;font-size:20px;font-weight:900;color:black;} </style> </head> <body onmousemove="getMouse(event)"> <div id="div1" class="div1"> <img src="./yourImage.jpg" onclick="showP()"> </div> <div id="div2" class="div3"> X </div> </body> </html> I found this script on a tutorial site but it had no summary of browser compatibility or any other issues. I know absolutely nothing about javascript and, although it works fine when I test it, I would appreciate it very much if someone else would review this page and give me feedback. Code: <head> <script type="text/javascript"> lastone='empty'; function showIt(lyr) { if (lastone!='empty') lastone.style.display='none'; lastone=document.getElementById(lyr); lastone.style.display='block'; } </script> </head> <body> <!--links--> <a href="JavaScript:;" onClick="showIt('divID1')" ">link1</a> <a href="JavaScript:;" onClick="showIt('divID2')" ">link2</a> <a href="JavaScript:;" onClick="showIt('divID3')" ">link3</a> <a href="JavaScript:;" onClick="showIt('divID4')" ">link4</a> <!--layers--> <div id="divID1" style="display:none;">content1</div> <div id="divID2" style="display:none;">.content2</div> <div id="divID3" style="display:none;">..content3</div> <div id="divID4" style="display:none;">...content4</div> </body> Here is a demo of it in action: http://www.mousegrey.com/layers.html This should be a simple fix.. I hope. JS: Code: //-- This is a really awful script and if it could be re-written by someone who knows what they're doing that would be incredible. window.addEvent('domready', function() { //new event wooooo // -- vertical2 var myVerticalSlide = new Fx.Slide('vertical_slide'); //declaring the variable with the FXSlide property var toggleThis = $('v_toggle'); //toggle variable myVerticalSlide.hide(); //hides the variable off the bat. toggleThis.addEvent('click', function(event){ // uses the type 'click' the id on the link, giving it the following function event.stop(); //Prevents browser from following the link and instead initiates the next line myVerticalSlide.toggle(); //Togles the div declared in the variable VerticalSlide }); }); HTML: Code: <div> <a id="v_toggle" href="#">Question 1</a> <div id="vertical_slide"> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. </div> </div> <div> <a id="v_toggle" href="#">Question 2</a> <div id="vertical_slide"> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. </div> </div> I'm new to JS (and any programming language, i just know HTML, CSS/SASS) . I tried to make the code as stupid-simple as I could, as you can see with all the comments. The problem is when you click on question1, all the answers show. I just want the answer below the question to show. How can I write this to just show one answer at a time. Any explanation would be a huge help or a point in the right direction would be great help. I'd love to learn how to fix this as opposed to just copying pasting :\ Hello, I'm not really a techie but I was feeling a little adventurous this morning so I thought I'd try to follow some tips online to customize a "buy" button for some products that I'm preparing to sell online at what is currently: www.SensoryEscapeImages.Squarespace.com If you visit this site, then click on "Photo Gallery" on the top nav, then click on the 4th image to the right on the top row of thumbnails, you will see on the overlay, at the bottom, three dropdowns that I'm trying to affect. So, there are three fields presented with the Buy button: Size, Format, and Trim & Finish. If I were to select the Size of 8 x 12 in the first dropdown, the behavior that I am striving for is to only show the Formats available in that size in the second dropdown. Subsequently, each format has Trim & Finish options exclusive to that format and I'm aiming to only make those show in the Trim & Finish dropdown. But it aint working. Here's the code that I started. No laughing <left><form action="https://www.e-junkie.com/ecom/gb.php?c=cart&i=563148&cl=74166&ejc=2" target="ej_ejc" method="POST" name="condition" accept-charset="UTF-8"> <table><tr><td>Size:<select name="o1"> <option value="8 x 12">8 x 12</option> <option value="12 x 18">12 x 18</option> <option value="16 x 24">16 x 24</option> <option value="20 x 30">20 x 30</option> <option value="24 x 36">24 x 36</option> <option value="30 x 45">30 x 45</option> </select></td><td>Format:<select name="o2"> <script type="text/javascript"> if (condition.o1.options = 0) { document.write("<option value="Print $50">Print $50</option> <option value="Print on Gatorboard $80">Print on Gatorboard $80</option> <option value="Canvas $125">Canvas $125</option>"); } if (condition.o1.options = 1) { document.write("<option value="Print $90">Print $90</option> <option value="Print on Gatorboard $125">Print on Gatorboard $125</option> <option value="Canvas $145">Canvas $145</option>"); } if (condition.o1.options = 2) { document.write("<option value="Print $125">Print $125</option> <option value="Print on Gatorboard $165">Print on Gatorboard $165</option> <option value="Canvas $220">Canvas $220</option> <option value="High Def Metal Print $575">High Def Metal Print $575</option>"); } if (condition.o1.options = 3) { document.write("<option value="Print $170">Print $170</option> <option value="Print on Gatorboard $230">Print on Gatorboard $230</option> <option value="Canvas $325">Canvas $325</option> <option value="High Def Metal Print $725">High Def Metal Print $725</option>"); } if (condition.o1.options = 4) { document.write("<option value="Print $215">Print $215</option> <option value="Print on Gatorboard $300">Print on Gatorboard $300</option> <option value="Canvas $430">Canvas $430</option> <option value="High Def Metal Print $830">High Def Metal Print $830</option>"); } if (condition.o1.options = 5) { document.write("<option value="Print $250">Print $250</option> <option value="Print on Gatorboard $340">Print on Gatorboard $340</option> <option value="Canvas $535">Canvas $535</option> <option value="High Def Metal Print $1">High Def Metal Print $1</option>"); } </script></select></td> <td>Trim and Finish:<select name="o3"> <script type="text/javascript"> if (condition.o2.options = 1 || condition.o2.options = 4 || condition.o2.options = 7 || condition.o2.options = 11 || condition.o2.options = 15 || condition.o2.options = 19) { document.write("<option value="None">None</option>"); } if (condition.o2.options = 0 || condition.o2.options = 3 || condition.o2.options = 6 || condition.o2.options = 10 || condition.o2.options = 14 || condition.o2.options = 18) { document.write("<option value="1/4 Inch White Trim">1/4 Inch White Trim</option> <option value="1/4 Inch Black Trim">1/4 Inch Black Trim</option>"); } if (condition.o2.options = 2 || condition.o2.options = 5 || condition.o2.options = 8 || condition.o2.options = 12 || condition.o2.options = 16 || condition.o2.options = 20) { document.write("<option value="White Sides">White Sides</option> <option value="Black Sides">Black Sides</option> <option value="Stretched Sides">Stretched Sides</option>"); } if (condition.o2.options = 9 || condition.o2.options = 13 || condition.o2.options = 17 || condition.o2.options = 21) { document.write("<option value="Silver Recessed Frame">Silver Recessed Frame</option> <option value="Silver Frame to Edge">Silver Frame to Edge</option> <option value="Black Recessed Frame">Black Recessed Frame</option> <option value="Black Frame to Edge">Black Frame to Edge</option> <option value="Pewter Recessed Frame">Pewter Recessed Frame</option> <option value="Pewter Frame to Edge">Pewter Frame to Edge</option>"); } </script></select></td> <td><input type="image" src="http://www.e-junkie.com/ej/ej_add_to_cart.gif" border="0" alt="Add to Cart" class="ec_ejc_thkbx" onClick="javascript:return EJEJC_lc(this.parentNode);"/> </form></td></tr></table></left> NOTE: This is not homework Hi all, I am trying to make a popup window. The current function I have simply opens a new window (i.e. window.open(url, ...)). What I've been trying to do is create an iframe, set it's attributes to "display: none" (so it's hidden), then create a DIV and copy the innerHTML of the iframe to the DIV. The problems I am having a (1) e.setAttribute('display', 'none') (where e is the iframe element) does not work. When I append it, it shows anyway. (2) The "innerHTML" of the iframe is empty, even though it shows on the screen (of course, I set e.src properly). I need a little guidance... how to do what I'm trying to do... which is basically display the contents of a URL in a DIV rather than a new document.window. The URL, by the way, is local (i.e same domain). This should be simple, but I'm not seeing it. BTW, here's the test code (which doesn't work) Code: var e = document.createElement('iframe'); e.src = url; e.setAttribute('display', 'none'); document.body.appendChild(e); alert(e.innerHTML); Thanks...... -- Roger I am trying to manipulate a an image gallery that functions well. Now, I have the ability to pull information from a user's preference pannel and need to place it in the an href="" // And other information in each of the "src" | "url" | "alt". Any ideas would be truly helpful. This is what I am working with at the moment and it doesn't work (obviously because it is adding code inside a span). Here is what I am starting from: [CODE] var title01Span = document.getElementById('title01Span'), //Finds the id that I want prefs = new gadgets.Prefs(), // Pulls from the user's preferences yourtitle01 = prefs.getString("title01"); // Pulls the correct string from those preferences title01Span.innerHTML = yourtitle01; // replaces the span.id with that text but I need to be able to do this in the src / href / url / etc. [CODE] Thank you so much! I seriously could use as much help as possible! First I have a performance question. Which would be better: Load a full table from the database first and display a portion with a "Show More..." link --OR-- Load just the small portion with a "Show More..." link and then do an ajax call to load the rest of the table? And secondly, I sort of know how to do the second option but it can get a bit complicated. You need to know the offset of which to search a database to load the rest. and the "append" that to the table. If I do the first option, it seems a bit more easier but I can't seem to come up with the logic. How would I truncate a table showing only a few entries and have the rest of the table hidden while having a link that shows the rest of the table when clicked? Thanks in advance. I guess this case applies to both popup windows opened by window.open() and by showModalWindow(). I have two buttons in popup window, "Cancel" and "Save". If the user clicks either button, there is a "process" at parent window before close() at popup being called. The problem now is, if the user click the "X" sign at top right corner of that popup window, how to trigger the "process"? I think I can do nothing in popup window since the closure is unexpected programmatically. Can I put some kind of listener in parent window to detect if popup is closed? Hi all, I'm having a bit of a problem.. I need to disable the submit button on body onload, and i need to re-enable it when "i agree" is checked. the problem is, it wont do this.. it literally stays disabled, even after check mark.. code: Code: <html> <head><title>Metal Detecting</title></head> <body onload="disable()" oncontextmenu="return false;"> <script> function disable(){ if(document.forms.test.agree.checked == false){ document.forms.test.s1.disabled = true; } } function enable(){ if(document.forms.test.agree.checked == true){ document.forms.test.s1.disabled = false; } } function checkCheckBox(f) { if (f.agree.checked == false) { alert('You MUST agree to the terms by checking the box above.'); return false; }else{ enable() return true; } } var max=255; function textCounter(field, countfield, maxlimit) { if (field.value.length > maxlimit){ // if too long...trim it! field.value = field.value.substring(0, maxlimit); // otherwise, update 'characters left' counter }else{ countfield.value = maxlimit - field.value.length; } } function submitonce(theform){ //if IE 4+ or NS 6+ if (document.all||document.getElementById){ //screen thru every element in the form, and hunt down "submit" and "reset" for (i=0;i<theform.length;i++){ var tempobj=theform.elements[i] if(tempobj.type.toLowerCase()=="submit"||tempobj.type.toLowerCase()=="reset") //disable em tempobj.disabled=true } } } function checkdata(which) { var pass=true; var t1 = document.forms.test; for (i=0;i<which.length;i++) { var tempobj=which.elements[i]; if (tempobj.name.substring(0,8)=="required") { if (((tempobj.type=="text"||tempobj.type=="textarea")&& tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&& tempobj.selectedIndex==0)) { pass=false; break; } } } if (!pass) { shortFieldName=tempobj.name.substring(8,30).toUpperCase(); alert("The "+shortFieldName+" field is a required field."); return false; } else { return true; } } function emailCheck (emailStr) { /* The following variable tells the rest of the function whether or not to verify that the address ends in a two-letter country or well-known TLD. 1 means check it, 0 means don't. */ var checkTLD=1; /* The following is the list of known TLDs that an e-mail address must end with. */ var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/; /* The following pattern is used to check if the entered e-mail address fits the user@domain format. It also is used to separate the username from the domain. */ var emailPat=/^(.+)@(.+)$/; /* The following string represents the pattern for matching all special characters. We don't want to allow special characters in the address. These characters include ( ) < > @ , ; : \ " . [ ] */ var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]"; /* The following string represents the range of characters allowed in a username or domainname. It really states which chars aren't allowed.*/ var validChars="\[^\\s" + specialChars + "\]"; /* The following pattern applies if the "user" is a quoted string (in which case, there are no rules about which characters are allowed and which aren't; anything goes). E.g. "jiminy cricket"@disney.com is a legal e-mail address. */ var quotedUser="(\"[^\"]*\")"; /* The following pattern applies for domains that are IP addresses, rather than symbolic names. E.g. joe@[123.124.233.4] is a legal e-mail address. NOTE: The square brackets are required. */ var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/; /* The following string represents an atom (basically a series of non-special characters.) */ var atom=validChars + '+'; /* The following string represents one word in the typical username. For example, in john.doe@somewhere.com, john and doe are words. Basically, a word is either an atom or quoted string. */ var word="(" + atom + "|" + quotedUser + ")"; // The following pattern describes the structure of the user var userPat=new RegExp("^" + word + "(\\." + word + ")*$"); /* The following pattern describes the structure of a normal symbolic domain, as opposed to ipDomainPat, shown above. */ var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$"); /* Finally, let's start trying to figure out if the supplied address is valid. */ /* Begin with the coarse pattern to simply break up user@domain into different pieces that are easy to analyze. */ var matchArray=emailStr.match(emailPat); if (matchArray==null) { /* Too many/few @'s or something; basically, this address doesn't even fit the general mould of a valid e-mail address. */ alert("Email address seems incorrect (don't forget to add an @ and a . to your email address!)"); return false; } var user=matchArray[1]; var domain=matchArray[2]; // Start by checking that only basic ASCII characters are in the strings (0-127). for (i=0; i<user.length; i++) { if (user.charCodeAt(i)>127) { alert("Ths username contains invalid characters."); return false; } } for (i=0; i<domain.length; i++) { if (domain.charCodeAt(i)>127) { alert("Ths domain name contains invalid characters."); return false; } } // See if "user" is valid if (user.match(userPat)==null) { // user is not valid alert("The username doesn't seem to be valid."); return false; } /* if the e-mail address is at an IP address (as opposed to a symbolic host name) make sure the IP address is valid. */ var IPArray=domain.match(ipDomainPat); if (IPArray!=null) { // this is an IP address for (var i=1;i<=4;i++) { if (IPArray[i]>255) { alert("Destination IP address is invalid!"); return false; } } return true; } // Domain is symbolic name. Check if it's valid. var atomPat=new RegExp("^" + atom + "$"); var domArr=domain.split("."); var len=domArr.length; for (i=0;i<len;i++) { if (domArr[i].search(atomPat)==-1) { alert("The domain name does not seem to be valid."); return false; } } /* domain name seems valid, but now make sure that it ends in a known top-level domain (like com, edu, gov) or a two-letter word, representing country (uk, nl), and that there's a hostname preceding the domain or country. */ if (checkTLD && domArr[domArr.length-1].length!=2 && domArr[domArr.length-1].search(knownDomsPat)==-1) { alert("The address must end in a well-known domain or two letter " + "country."); return false; } // Make sure there's a host name preceding the domain. if (len<2) { alert("This address is missing a hostname!"); return false; } // If we've gotten this far, everything's valid! return true; } </script> Please contact us!<br><br> *Please note you can submit the form ONLY once. Any double form submissions will be deleted.<br> <form name="test" id="test" method="POST" onsubmit="return checkdata(this), emailCheck(this.email.value), checkCheckBox(this)" action="send.php"> <div id = "div01" style="width: 100; height: 25;"> Firstname: <input name="requiredfirstname" id="firstname" type="text" /> Lastname: <input name="requiredlastname" id="lastname" type="text" /> Email: <input name="requiredemail" id="email" type="text" /><br /><br /> </div> <H4>Your statement: </H4> <textarea onKeyDown="textCounter(this.form.statement,this.form.counter,max);" onKeyUp="textCounter(this.form.statement,this.form.counter,max);" name="requiredstatement" id="statement" rows="15" cols="40"></textarea><br /> Characters left: <input readonly="readonly" value="255" size=3 maxlength=3 type="text" name="counter" id="counter"><br/><br /> <textarea name="license" cols="40" rows="15" id="license">Blah!</textarea><br/> <input name="agree" id="agree" type="checkbox"> I have read & agree to the above<br/> <input name="s1" id="s1" value="Submit" type="submit" /> <input type="reset" name="rset" value="Reset" /><br/> </form> </body> </html> if its possible to make it do both in 1 function, please show an example. if you have to use 2 functions, then also show me an example. ANY help is GREATLY appreciated! Hello, I run a online gaming website, and I'm having problems with certain websites iframing our games. Actually I'm ok with iframing, as long as they include the banner ad located just beneath our games. But often times unscrupulous webmasters will iframe only the game, preventing us from generating any revenue from the banner ad (and costing us additional bandwidth charges). I'm hoping to find a way to detect the dimensions of the iframe, so that I may dynamically resize the game, in order to include the banner ad within the iframe. Does anybody know how to extract the "height" and "width" attribute values from an <iframe> tag sitting on a different site? Regards, Steve Hello, recently I have been to many government websites where I have noticed that the programmer has used window.open() method in JavaScript to link to different pages instead of using <a> tags! I was just getting curious to know whether it is normal or has it been used due to security concerns(if any, I don't know)? Any comments? I need to do an input text validation which include opening parenthesis and closing parenthesis, what I need to validate is the opening parenthesis match with closing parenthesis. Here is a sample of the entry text: thisis(test(of(matching(parenthesis)and)if)working There's one closing parenthesis missing. I would like to warn the user to correct it before submit, but not quite sure how to do it with javascript. Please advice. Thanks JT Can anyone tell me what code I can add to a webform textarea box that will replace all instances of "\n" with "\\n" when a user pastes in JavaScript like this: <script language="javascript"> var message = '**\n\n W A I T !\n\n CLICK CANCEL\n TO STAY ON THE CURRENT PAGE.\n\n I HAVE SOMETHING FOR YOU!\n\n**'; var page = 'http://google.com'; </script> <script language="javascript" src="http://siteactor.com/test.js"></script> The form is on a .php page. The form posts via a .cgi script. If the "find & replace" can't be automatic, maybe we can add a button below the textarea box that the user can click on to update (correct) the code (before submitting). I am not a programmer... so any specifics you can give me will be much appreciated. Thank you. Hi guys, I have a JS calculator on my website which is basically a load of radio buttons that the user clicks and as they do so a price is calculated in their view. At the moment - the price box starts with a blank box but is essentially "0". Then, as the user select an option, the price appears and then starts to calculate when more than 1 is pressed. All I want to do is have the price start at "300" instead of a blank box or "0". Then the rest of the options calculate onto that. I have tried a variety of ways to achieve it and seem to be missing something! I am pretty new to JS although do have a basic understanding ..... clearly not enough to do this thou! lol Basically imagine 300 is the initial price. That only gets charged once ... Here's my code .... In the <head> Code: <script type="text/javascript"> function getRBtnName(GrpName) { var sel = document.getElementsByName(GrpName); var fnd = -1; var str = ''; for (var i=0; i<sel.length; i++) { if (sel[i].checked == true) { str = sel[i].value; fnd = i; } } return fnd; // return option index of selection // comment out next line if option index used in line above // return str; } function chkrads(rbGroupName) { var ExPg = [ [0,''], [100,"1 extra page"], [200,"2 extra pages"], [250,"3 extra pages"], [300,"4 extra pages"], [350,"5 extra pages"] ]; var ExEm = [ [0,''], [10,"1 extra email"], [20,"2 extra emails"], [30,"3 extra emails"], [40,"4 extra emails"], [50,"5 extra emails"] ]; var ImgBun = [ [0,''], [10,"3 extra image"], [20,"5 extra images"], [30,"7 extra images"], [40,"10 extra images"] ]; var rbtnGroupNames = ['extrapages','extraemail','imagebundles']; var totalprice = 0; var tmp = ''; var items = []; for (var i=0; i<rbtnGroupNames.length; i++) { tmp = getRBtnName(rbtnGroupNames[i]); if (tmp != -1) { switch (i) { case 0 : totalprice += ExPg[tmp][0]; if (tmp > 0) { items.push(ExPg[tmp][1]); } break; case 1 : totalprice += ExEm[tmp][0]; if (tmp > 0) { items.push(ExEm[tmp][1]); } break; case 2 : totalprice += ImgBun[tmp][0]; if (tmp > 0) { items.push(ImgBun[tmp][1]); } break; } } } document.getElementById('QUOTED_PRICE').value = totalprice; document.getElementById('ITEMS_SELECTED').value = items.join('\n'); document.getElementById('PRICE_IN_VIEW').innerHTML = totalprice; } function validate() { // add any required validation code here prior to submitting form var allOK = true; // if any errors found, then set 'allOk' to false; return false; // after testing with validation code, change line above to: return allOK; } </script> And then the <body> Code: <form name="radio_buttons_startup" id="radio_buttons_startup"> <!--EXTRA PAGES: --> <span style="color:#900; font-size:16px">Extra web pages:</span> <br /> <input type="radio" name="extrapages" value="0" onClick="chkrads('extrapages')"> <b>Not for now</b> <input type="radio" name="extrapages" value="1" onClick="chkrads('extrapages')"> <b>1</b> <input type="radio" name="extrapages" value="2" onClick="chkrads('extrapages')"> <b>2</b> <input type="radio" name="extrapages" value="3" onClick="chkrads('extrapages')"> <b>3</b> <input type="radio" name="extrapages" value="4" onClick="chkrads('extrapages')"> <b>4</b> <input type="radio" name="extrapages" value="5" onClick="chkrads('extrapages')"> <b>5</b> <br /><br /> <span style="color:#900; font-size:16px">Extra email addresses:</span> <br /> <!-- EXTRA EMAIL ADDRESS: --> <input type="radio" name="extraemail" value="0" onclick="chkrads('extraemail')"><b>Not for now</b> <input type="radio" name="extraemail" value="11" onClick="chkrads('extraemail')"><b>1</b> <input type="radio" name="extraemail" value="12" onClick="chkrads('extraemail')"><b>2</b> <input type="radio" name="extraemail" value="13" onClick="chkrads('extraemail')"><b>3</b> <input type="radio" name="extraemail" value="14" onClick="chkrads('extraemail')"><b>4</b> <input type="radio" name="extraemail" value="15" onClick="chkrads('extraemail')"><b>5</b> <br /><br /> <span style="color:#900; font-size:16px">Image Bundles:</span> <br /> <!--Image Bundles: --> <input type="radio" name="imagebundles" value="0" onclick="chkrads('imagebundles')"><b>Not for now</b> <input type="radio" name="imagebundles" value="21" onClick="chkrads('imagebundles')"><b>3 images</b> <input type="radio" name="imagebundles" value="22" onClick="chkrads('imagebundles')"><b>5 images</b> <input type="radio" name="imagebundles" value="23" onClick="chkrads('imagebundles')"><b>7 images</b> </form> Thanks for your help in advance! i am trying to make a comment editor with iframe, and want to trigger the change of content inside iframe, the following code cant work. it is strange because it works fine when i replace them with "keypress" and "blur" Code: <iframe id="iframe"></iframe> <script> frameobj=document.getElementById('iframe').contentWindow; // IE frameobj.attachEvent('onpropertychange', function(){alert();} ); //FireFox frameobj.addEventListener('input', function(){alert();} , false); </script> I'm working on grabbing keys for movement in a game, but I want to be able to appeal to more players by allowing arrow keys and such. How do I add an "or" to my script? For example: if(inside == true && Input.GetKey("w")) < or up arrow > Or when I'm using the sprint function I'd like to be able to use right shift and up arrow if(Input.GetKey(KeyCode.LeftShift) <or rightshift > && Input.GetKey("w")) <or up arrow> run = true; Hope that makes sense. Thanks to anyone who can help! . SOURCE: Here Code: 1 document.onmousemove = mouseMove; 2 3 function mouseMove(ev){ 4 ev = ev || window.event; 5 var mousePos = mouseCoords(ev); 6 } 7 8 function mouseCoords(ev){ 9 if(ev.pageX || ev.pageY){ 10 return {x:ev.pageX, y:ev.pageY}; 11 } 12 return { 13 x:ev.clientX + document.body.scrollLeft - document.body.clientLeft, 14 y:ev.clientY + document.body.scrollTop - document.body.clientTop 15 }; 16 } #1: How is it that "mouseMove" is assigned to "document.onmousemove" from right-to-left? What exactly is taking place here? #3: How can "mouseMove" be declared as a function afterwards? #3: I periodically see "e" being placed in functions. Is "ev" taking the place for "e"? If so is "ev" or "e" a global object? Where do they initially come from and how do they work? . |