JavaScript - Is 'read" A Reserved Variable?
This little snippet tells me that using "read" as the saved cookie doesn't work.
But using "listen" "speak" "write" etc. works OK. Code: else if (lessonnum == "reading"){ // oddly, "read" as cookie value fails. Why? so.addVariable('file','/images/101online/Introduction/readsubtest/audioRead.mp3'); } I had to change it to "reading". Is this normal? Is there a place where I can find all the reserved values that won't work as cookie drops? Similar TutorialsHad no replies to my previous post ! http://www.codingforums.com/search.php?searchid=6740324 I have tried to manipulate some (pretty complex) code for reading external code seen here on CF but there was nothing on doing this in a "For Loop" so had no real success Can anyone assist ? Most Kind Function to Read-In External "XML" datafiles on For Loop Can anyone help ? see: http://www.jcsweb.biz/mef/AnimGIF/XMLtemp_04c.htm for required output Javascript Function required: To read in 7 successive "XML" files (not pure XML format & held in "Gallery/Data" external dir in a For Loop: (US_SUMlev_2008.xml,US_SUMlev_2009.xml.....to US_SUMlev_2014.xml) These XML then succesively update a string variable "strXML" which forms the "data" populating a time-series chart. "strXML" then acts as the input to "setDataXML" which is the Chart's data update method (?) The sequential updating of "strXML" in a For Loop should the create a psuedo-animation effect in the chart. My code (see below in edited format or view source at above URL) will achieve what I want but the "strXML" variable update is currently HARD-CODED (rather than read from the XML files held in external directory "Gallery/Data" ). The required function will also need to strip out all linbreaks ("\n") from the external XML files in order to produce a single line of stringtext: eg HTML Code: Code: <chart animation='0' caption= 'Chart1' yAxisName=' % change' ><categories> <category label='2008' /> <category label='2009' /> <category label='2010' /> <category label='2011' /> <category label='2012' /> <category label='2013' /> <category label='2014' /></categories><dataset seriesName='zGDP_u' color='6600CC' renderAs='Column' dashed='1'><set value='0.000000' /></dataset><dataset seriesName='zCPI_u' color='0000DC' renderAs='Line' ><set value='0.000000' /></dataset><dataset seriesName='ERIb_u' color='FFAA26' renderAs='Line' ><set value='0.000000' /></dataset><dataset seriesName='RSH_u' color='FF0066' renderAs='Line' ><set value='0.000000' /></dataset><dataset seriesName='zER_u' color='00FF00' renderAs='Line' ><set value='0.000000' /></dataset></chart> The sequential updating of "strXML" is also NOT yet done in a For Loop but a fixed timing Animate() function which successivley activates the generateXML_200?() on a timedelay. Summary: Required Runstream in Function For Loop: Loop1: Read-in "Gallery/Data/US_SUMlev_2008.xml", strip out "\n", update strXML (& thus setDataXML) & update chart1 Loop2: Read-in "Gallery/Data/US_SUMlev_2009.xml", strip out "\n", update strXML (& thus setDataXML) & update chart1 etc etc until Loop7: Read-in "Gallery/Data/US_SUMlev_2014.xml", strip out "\n", update strXML (& thus setDataXML) & update chart1 If there was a way to "Freeze" and "Restart" this above function (ie pause the read-in of the next XML) as in current code that would be mighty fine too. Any help much appreciated Code: Code: <HTML> <HEAD> <script language="Javascript" SRC="FC_v3_2.js"></script> <script language="JavaScript"> var strXML; function generateXML_2008(){ strXML = "<chart animation='0' caption= 'Chart1' yAxisName=' % change' ><categories> <category label='2008' /> <category label='2009' /> <category label='2010' /> <category label='2011' /> <category label='2012' /> <category label='2013' /> <category label='2014' /></categories><dataset seriesName='zGDP_u' color='6600CC' renderAs='Column' dashed='1'><set value='0.000000' /></dataset><dataset seriesName='zCPI_u' color='0000DC' renderAs='Line' ><set value='0.000000' /></dataset><dataset seriesName='ERIb_u' color='FFAA26' renderAs='Line' ><set value='0.000000' /></dataset><dataset seriesName='RSH_u' color='FF0066' renderAs='Line' ><set value='0.000000' /></dataset><dataset seriesName='zER_u' color='00FF00' renderAs='Line' ><set value='0.000000' /></dataset></chart>" ; return strXML; } function generateXML_2009(){ TRUNCATED - extends data by 1 year} function generateXML_2010(){ TRUNCATED - extends data by 1 year} function generateXML_2011(){ TRUNCATED - extends data by 1 year} function generateXML_2012(){ TRUNCATED - extends data by 1 year} function generateXML_2013(){ TRUNCATED - extends data by 1 year} function generateXML_2014(){ strXML = "<chart animation='0' showValues='0' caption= 'Chart1' yAxisName=' % change' ><categories> <category label='2008' /> <category label='2009' /> <category label='2010' /> <category label='2011' /> <category label='2012' /> <category label='2013' /> <category label='2014' /></categories><dataset seriesName='zGDP_u' color='6600CC' renderAs='Column'><set value='0.000000' /><set value='-0.055113' /><set value='-0.022272' /><set value='0.052834' /><set value='0.029910' /><set value='0.016847' /><set value='0.003139' /></dataset><dataset seriesName='zCPI_u' color='0000DC' renderAs='Line' ><set value='0.000000' /><set value='0.000470' /><set value='-0.009643' /><set value='0.004135' /><set value='0.000321' /><set value='0.000019' /><set value='-0.000719' /></dataset><dataset seriesName='ERIb_u' color='FFAA26' renderAs='Line' ><set value='0.000000' /><set value='0.142439' /><set value='0.130952' /><set value='0.102297' /><set value='0.083231' /><set value='0.062888' /><set value='0.043371' /></dataset><dataset seriesName='RSH_u' color='FF0066' renderAs='Line' ><set value='0.000000' /><set value='0.238348' /><set value='0.000000' /><set value='0.002127' /><set value='0.001261' /><set value='0.011962' /><set value='0.015624' /></dataset><dataset seriesName='zER_u' color='00FF00' renderAs='Line' ><set value='0.000000' /><set value='-0.000155' /><set value='-0.006479' /><set value='-0.007280' /><set value='-0.000895' /><set value='0.003701' /><set value='0.005333' /></dataset></chart>" ; return strXML; } </script> <script language="JavaScript"> function UpdatestrXML_2008(){ var chartObj = getChartFromId("chart1Id"); //Get reference to chart object using Dom ID chartObj.setDataXML(generateXML_2008()); } //Update XML going to Fusion charts function UpdatestrXML_2009(){ var chartObj = getChartFromId("chart1Id"); //Get reference to chart object using Dom ID chartObj.setDataXML(generateXML_2009()); } //Update XML going to Fusion charts function UpdatestrXML_2010(){ var chartObj = getChartFromId("chart1Id"); //Get reference to chart object using Dom ID chartObj.setDataXML(generateXML_2010()); } //Update XML going to Fusion charts function UpdatestrXML_2011(){ var chartObj = getChartFromId("chart1Id"); //Get reference to chart object using Dom ID chartObj.setDataXML(generateXML_2011()); } //Update XML going to Fusion charts function UpdatestrXML_2012(){ var chartObj = getChartFromId("chart1Id"); //Get reference to chart object using Dom ID chartObj.setDataXML(generateXML_2012()); } //Update XML going to Fusion charts function UpdatestrXML_2013(){ var chartObj = getChartFromId("chart1Id"); //Get reference to chart object using Dom ID chartObj.setDataXML(generateXML_2013()); } //Update XML going to Fusion charts function UpdatestrXML_2014(){ var chartObj = getChartFromId("chart1Id"); //Get reference to chart object using Dom ID chartObj.setDataXML(generateXML_2014()); } //Update XML going to Fusion charts </script> <script language="JavaScript"> var start = 250 ; var delay = 350 // var delay = 2000 function Animate() { t1_2008=setTimeout("javascript:UpdatestrXML_2008();", start+delay*1 ) ; t1_2009=setTimeout("javascript:UpdatestrXML_2009();", start+delay*2 ) ; t1_2010=setTimeout("javascript:UpdatestrXML_2010();", start+delay*3 ) ; t1_2011=setTimeout("javascript:UpdatestrXML_2011();", start+delay*4 ) ; t1_2012=setTimeout("javascript:UpdatestrXML_2012();", start+delay*5 ) ; t1_2013=setTimeout("javascript:UpdatestrXML_2013();", start+delay*6 ) ; t1_2014=setTimeout("javascript:UpdatestrXML_2014();", start+delay*7 ) ; LOOP =setTimeout("javascript:Animate();", start+delay*8) ; } </script> <script language="JavaScript"> function FreezeAll() { clearTimeout(t1_2008); clearTimeout(t1_2009); clearTimeout(t1_2010); clearTimeout(t1_2011); clearTimeout(t1_2012); clearTimeout(t1_2013); clearTimeout(t1_2014); clearTimeout(LOOP); } </script> </HEAD> <body onload="Animate();" > <FORM NAME='Form1' Id='Form1' action='' method=''> <INPUT TYPE="button" class="button" value="Animate" onClick="Animate(); "> <INPUT TYPE="button" class="button" value="Freeze" onClick="FreezeAll();"> </FORM> <div id="chart1div"> FusionCharts </div> <script language="JavaScript"> var chart1 = new FusionCharts("MSColumnLine3D.swf", "chart1Id", "600", "400", "0", "1"); chart1.setDataXML("<chart></chart>"); //Initialize chart with empty data. We'll feed it data on the chart's FC_Rendered event. chart1.render("chart1div"); </script> </body> </HTML> Hi, I have a programing problem that have been around for ages. I have search on google using several expressions and words and after hours of digging i'm still unable to do it. I would like to get a value from a HTML page hosted remotely with an inconstant value. Then define this value and name as a javascript variable and apply or show in my page. Thanks for all the help P.S. Is there any way to make a domain lookup in javascript? I mean a user enters a domain and the script converts to an ip and shows to the user. If not thanks, probably it can only be done in the server side... hi , i am trying to pass a javascript variable into URL ..but not getting the value.. var newID = 2; row.insertCell(6).innerHTML = "<a href=Update_Gate.cfm?GateIdVar=newID>Edit Gate</a>"; i am getting "newID" in Update_Gate.cfm page ... i want to pass this javascript variable in url and read it on the other page as form field value any help !! Hi there I'm nearly completed on a game, and want to bring in "Lives", basically, rather than the game ending, running "function EndGame ()" I want to allow the player to carry on with "Lives", 3 in fact. Basically, when the player presses a wrong tile, the game needs to carry on, until the last life, life 3 is lost, then "function EndGame ()" runs.. I believe a Global Variable needs to be used? If any help could be given that would be great, also if it could be shown in JSFiddle, that would be great! Many thanks Reply With Quote 12-18-2014, 03:56 PM #2 Dormilich View Profile View Forum Posts Senior Coder Join Date Jan 2010 Location Behind the Wall Posts 3,532 Thanks 13 Thanked 372 Times in 368 Posts Originally Posted by LONDONLAD I believe a Global Variable needs to be used? nope. you can use a global, but you should not. better use the variable/container that you store the player or game status in. hi all, I am fairly new to Javascript, and am trying to "print" a var inside a script. I have this piece of script, which loads images from a gallery: Code: $(document).ready(function(){ $('title').text('G3 Ajax Gallery'); loadGallery('/gallery3/rss/feed/gallery/album/114'); }); The number 114 defines what part of the gallery to be loaded. I would like to define this with a var, but dont know how to "print" it into the url. So: loadGallery('/gallery3/rss/feed/gallery/album/114'); woulkd become something like: loadGallery('/gallery3/rss/feed/gallery/album/my_var'); Any help would be much apreciated. Thanks, Sion. Reply With Quote 01-21-2015, 12:41 PM #2 xelawho View Profile View Forum Posts Senior Coder Join Date Nov 2010 Posts 3,043 Thanks 56 Thanked 568 Times in 565 Posts PHP Code: var myvar=114; // or however you are defining it loadGallery('/gallery3/rss/feed/gallery/album/' + myvar); Whenever this function sorts itself out, the value of the variable I want ends up "undefined". It starts here in my code with this link. $sort is the variable that's giving me trouble. If I echo it here, it works correctly. Code: <a id='showMoreLink' onclick='showMorePosts($showMoreCount,$sort)'>Show more...</a> Here is snippets of the showMorePosts function Code: function showMorePosts(str,sortBy) { xmlhttp.open('GET','ajaxQueries.php?sort='+sortBy+'&q='+str,true); xmlhttp.send(); } And here is where I am echoing $sort in ajaxQueries.php, and getting "undefined". Note that $q works just as it should. (All I can think is q is an integer, and sort is a string) PHP Code: $q=$_GET['q']; $sort=$_GET['sort']; echo $sort.$q; Okay so I have a form, and it has many options and the ability to select more than one. I can get a txt input div to show up if "Other" is selected with the below Javascript, but i need to add something else to the underlined area below, which will say something like "if which.value == "other" || "other" & "anything else", show the div." ...for you see, the div disappears again if you select "other" in addition to another option. Code: function showBox(which) { var d = which.id; if (d == "Referred_by") {var b = 1} if (d == "Bit_Rate") {var b = 2} if (d == "Samp_Rate") {var b = 3} if (d == "format") {var b = 4} if (d == "extension") {var b = 5} if (d == "turnaround") {var b = 6} if (d == "language") {var b = 7} if (which.value == "Other") { document.getElementById("inputBox" +b).style.display="block"; } else { document.getElementById("inputBox" +b).style.display="none"; } } help is appreciated! I have this function: Code: function SelectedRadio(form, name) { for(var i = 0; i < form.name.length; i++) { if(form.name[i].checked == true) { return form.name[i].value; } } return "Error!"; } Form is a form object, and name is a string of the name of the radio button. I thought it was trying to use the variable name as the name of a field. For example: Code: function OnFormSubmit(form) { SelectedRadio(form, "fruits") } Instead of form.fruits its using form.name. Basically I am trying to use the variable as a string. Is there anyway around this? 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! 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? 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 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! 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! 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. 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 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> . 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? . Code: for(i=0;i<document.getElementsByName('checkresult_".$i."').length;++i){ if(document.getElementsByName('checkresult_".$i."')[i].checked){ thisurlext+=document.getElementsByName('checkresult_".$i."')[i].value; checkedlength++; if(i+1<document.getElementsByName('checkresult_".$i."').length){ if(document.getElementsByName('checkresult_".$i."')[i+1].checked){ thisurlext+='+'; } } } }; Let's say I check verses 1, 2, 3, 6 I want the Javascript not to ignore the + between the 3 and the 6: Code: <div id="txt_kjv0_1_1_0" style="float: left; background-color: rgb(234, 232, 200); margin: 0px; width: 178px; height: 497px; border: 1px solid rgb(122, 16, 16); padding: 5px 5px 0px; overflow-y: auto; overflow-x: hidden;"> <input id="sc0" value="kjv" type="hidden"> <p id="regular[]" name="bibletext" style="float: left; text-align: left; width: 155px; display: block; padding: 0px 2px; font-size: 12px;"><input id="check0_0" name="checkresult_0" onclick="" value="1" type="checkbox"><span style="font-weight: bold; margin: 2px;">1</span>In the beginning God created the heaven and the earth.</p> <p id="regular[]" name="bibletext" style="float: left; text-align: left; width: 155px; display: block; padding: 0px 2px; font-size: 12px;"><input id="check0_1" name="checkresult_0" onclick="" value="2" type="checkbox"><span style="font-weight: bold; margin: 2px;">2</span>And the earth was without form, and void; and darkness was upon the face of the deep. And the Spirit of God moved upon the face of the waters.</p> <p id="regular[]" name="bibletext" style="float: left; text-align: left; width: 155px; display: block; padding: 0px 2px; font-size: 12px;"><input id="check0_2" name="checkresult_0" onclick="" value="3" type="checkbox"><span style="font-weight: bold; margin: 2px;">3</span>And God said, Let there be light: and there was light.</p> <p id="regular[]" name="bibletext" style="float: left; text-align: left; width: 155px; display: block; padding: 0px 2px; font-size: 12px;"><input id="check0_3" name="checkresult_0" onclick="" value="4" type="checkbox"><span style="font-weight: bold; margin: 2px;">4</span>And God saw the light, that it was good: and God divided the light from the darkness.</p> <p id="regular[]" name="bibletext" style="float: left; text-align: left; width: 155px; display: block; padding: 0px 2px; font-size: 12px;"><input id="check0_4" name="checkresult_0" onclick="" value="5" type="checkbox"><span style="font-weight: bold; margin: 2px;">5</span>And God called the light Day, and the darkness he called Night. And the evening and the morning were the first day.</p> <p id="regular[]" name="bibletext" style="float: left; text-align: left; width: 155px; display: block; padding: 0px 2px; font-size: 12px;"><input id="check0_5" name="checkresult_0" onclick="" value="6" type="checkbox"><span style="font-weight: bold; margin: 2px;">6</span>And God said, Let there be a firmament in the midst of the waters, and let it divide the waters from the waters.</p> |