JavaScript - Function To Read-in External "xml" Datafiles On For Loop
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> 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 First post here so... I have a few functions called by a form. Two examples are onclick in a form input and onkeyup in a form button. Code: function checkUsernameForLength(whatYouTyped) { var fieldset = whatYouTyped.parentNode; var txt = whatYouTyped.value; if (txt.length > 2) { fieldset.className = "welldone"; return true; } else { fieldset.className = ""; return false; } } Code: onkeypress="checkUsernameForLength(this);" There are a couple of the above "validation" functions. Each sets an input fieldset's class. Code: function verifyit() { var fieldsets = document.getElementsByTagName("fieldset"); var i=0; while (i<count(fieldsets)){ if (fieldsets[i] != "") { i++; document.form.submit(); } } } Code: onclick="verifyit()" The function above is where I'm having the trouble. I want to iterate through the fieldsets and make sure each class isn't blank before allowing the button to submit the form. I get an "object expected" error when I trigger the "verifyit" function with ie if it helps. I appreciate any input, thanks in advance for any help. Hey guys, This is my first time ever posting in a programming forum so please be nice! :) I'll admit right away that this is for a homework assignment, but I really did try to solve it myself before I decided to post here. The instructions are to have a confirm box pop up when links with the HTML class value "external" are clicked. If the user clicks "OK" they should be directed to the linked page. If they click "Cancel" they should not be directed anywhere. Here's my code: Code: function checkClass() { var links = document.getElementsByTagName("a"); for ( var i = 0 ; i < links.length ; i++ ) { var link = links[i]; if (link.className == "external") { link.onclick = clickHandler(); } } } window.onload = checkClass; function clickHandler() { if (confirm("You clicked an external link. Do you really want to leave this site?")) { return true; } return false; } The problem is that the confirm box is triggered on page load and not on link click. I know I wrote Code: window.onload = checkClass; but how else should I call the function? I thought Code: if (link.className == "external") would keep it from going as far as to the confirm box until an external link was clicked. Thanks for pointing me in the right direction, Johanna Hi all, Edit: Got it. I saved that source page and investigated closely and I realized that there's "Cookie plugin" script, which is not mentioned to add(?), in that tutorial I've been trying to implement the method given at http://dev.akabillposters.com/dom-js...-links-jquery/, but can't make it work. Nothing happens when I click the check box. I'm not a jquery expert, though tried some alerts statements to trace the issue, with no luck. Can anyone see what I'm missing? [link removed] Any help would be appreciated. Thanks. Hello, how could I run an external (but still on the same server) ".js" file from a <a href> or a button? Is it possible and how? Thanks. If you need any details just ask. I'm building a t-shirt shop whose interface includes a gallery of designs in an IFrame. When the user clicks on a design, a dedicated page is loaded into the IFrame which shows all the available products associated with the design the user clicked. I've put each design's image and associated page as the first and second elements of a nested array, and am using a for loop to then load all the images into the page that's shown in the IFrame when the web-site loads. It's looking beautiful, but here's the rub I've been stuck on for two days now with no solution in sight... The array, "designImages", has 37 elements (ie. designImages[0]... designImages[36]). When I click on a design image on the page, any design image, the browser (all browsers, so I can't blame Microsoft for this one ), loads the page for design #36. I've tried all sorts of things, but still cannot tell if the issue is because the dynamically generated divs are being reassigned the value [36] after the for loop's executed, or if the div id's are okay but somehow the code is rooting for [36], the last element of the array anyway. I need someone's help in enabling a click on #4 to load the page for #4, etc, etc. Here's the code below. Thanks. Code: /* designImages[x][0] = the image source on the page; * designImages[x][1] = the destination url on clicking the image; */ var designImages = new Array(); designImages[0] = new Array ( "Assets/DesignImages/Img00 - CosmicCircle.png" , "ProductGalleries/Img00.html" , "Cosmic Circles" , "Mark Lavin"); designImages[1] = new Array ( "Assets/DesignImages/Img01 - Flora.png" , "ProductGalleries/Img01.html" ); designImages[2] = new Array ( "Assets/DesignImages/Img02 - JBuddha.png" , "ProductGalleries/Img02.html" ); designImages[3] = new Array ( "Assets/DesignImages/Img03 - Ohm+Sun.png" , "ProductGalleries/Img03.html" ); designImages[4] = new Array ( "Assets/DesignImages/Img04 - Ohm+Burst.png" , "ProductGalleries/Img04.html" ); designImages[5] = new Array ( "Assets/DesignImages/Img05 - Space+Invader.png" , "ProductGalleries/Img05.html" ); designImages[6] = new Array ( "Assets/DesignImages/Img06 - Fire.png" , "ProductGalleries/Img06.html" ); designImages[7] = new Array ( "Assets/DesignImages/Img07 - Live.png" , "ProductGalleries/Img07.html" ); designImages[8] = new Array ( "Assets/DesignImages/Img08 - Being.png" , "ProductGalleries/Img08.html" ); designImages[9] = new Array ( "Assets/DesignImages/Img09 - Water.png" , "ProductGalleries/Img09.html" ); designImages[10] = new Array ( "Assets/DesignImages/Img10 - Abundance.png" , "ProductGalleries/Img10.html" ); designImages[11] = new Array ( "Assets/DesignImages/Img11 - Adventure.png" , "ProductGalleries/Img11.html" ); designImages[12] = new Array ( "Assets/DesignImages/Img12 - Air.png" , "ProductGalleries/Img12.html" ); designImages[13] = new Array ( "Assets/DesignImages/Img13 - Chance.png" , "ProductGalleries/Img13.html" ); designImages[14] = new Array ( "Assets/DesignImages/Img14 - Dangerous.png" , "ProductGalleries/Img14.html" ); designImages[15] = new Array ( "Assets/DesignImages/Img15 - Destiny.png" , "ProductGalleries/Img15.html" ); designImages[16] = new Array ( "Assets/DesignImages/Img16 - Dream.png" , "ProductGalleries/Img16.html" ); designImages[17] = new Array ( "Assets/DesignImages/Img17 - Earth.png" , "ProductGalleries/Img17.html" ); designImages[18] = new Array ( "Assets/DesignImages/Img18 - Ecstasy.png" , "ProductGalleries/Img18.html" ); designImages[19] = new Array ( "Assets/DesignImages/Img19 - Freedom.png" , "ProductGalleries/Img19.html" ); designImages[20] = new Array ( "Assets/DesignImages/Img20 - Friendship.png" , "ProductGalleries/Img20.html" ); designImages[21] = new Array ( "Assets/DesignImages/Img21 - Fulfillment.png" , "ProductGalleries/Img21.html" ); designImages[22] = new Array ( "Assets/DesignImages/Img22 - Generosity.png" , "ProductGalleries/Img22.html" ); designImages[23] = new Array ( "Assets/DesignImages/Img23 - Gift.png" , "ProductGalleries/Img23.html" ); designImages[24] = new Array ( "Assets/DesignImages/Img24 - Imagine.png" , "ProductGalleries/Img24.html" ); designImages[25] = new Array ( "Assets/DesignImages/Img25 - Joy.png" , "ProductGalleries/Img25.html" ); designImages[26] = new Array ( "Assets/DesignImages/Img26 - Kinky.png" , "ProductGalleries/Img26.html" ); designImages[27] = new Array ( "Assets/DesignImages/Img27 - Mystery.png" , "ProductGalleries/Img27.html" ); designImages[28] = new Array ( "Assets/DesignImages/Img28 - Mastery.png" , "ProductGalleries/Img28.html" ); designImages[29] = new Array ( "Assets/DesignImages/Img29 - Peace.png" , "ProductGalleries/Img29.html" ); designImages[30] = new Array ( "Assets/DesignImages/Img30 - Sexy.png" , "ProductGalleries/Img30.html" ); designImages[31] = new Array ( "Assets/DesignImages/Img31 - iBurn.png" , "ProductGalleries/Img31.html" ); designImages[32] = new Array ( "Assets/DesignImages/Img32 - PlayaTrash.png" , "ProductGalleries/Img32.html" ); designImages[33] = new Array ( "Assets/DesignImages/Img33 - Ohm+Burst.png" , "ProductGalleries/Img33.html" ); designImages[34] = new Array ( "Assets/DesignImages/Img34 - BlackRockCity.png" , "ProductGalleries/Img34.html" ); designImages[35] = new Array ( "Assets/DesignImages/Img35 - BarCode.png" , "ProductGalleries/Img35.html" ); designImages[36] = new Array ( "Assets/DesignImages/Img36 - NumberedBarCode.png" , "ProductGalleries/Img36.html" ); window.onload = function() { creationCompleteHandler(); } function creationCompleteHandler() { calcNumDesigns(); setLinks(); } function calcNumDesigns() { var numDesignBoxes = designImages.length; var numGalleryRows = Math.ceil( numDesignBoxes / 3 ); for ( n = 0 ; n <= numGalleryRows - 1 ; n++ ) { var newGalleryBox = document.createElement('div'); var newGalleryBoxID = ("galleryRow" + n); newGalleryBox.setAttribute('id',newGalleryBoxID); newGalleryBox.setAttribute('class',"galleryBox"); document.getElementById('content').appendChild(newGalleryBox); squareOff(newGalleryBox); var rowBoxes; if ( ( numDesignBoxes - ( n * 3 ) ) < 3 ) { rowBoxes = ( numDesignBoxes - ( n * 3 ) - 1 ) } else rowBoxes = 2; for ( m = 0 ; m <= rowBoxes ; m++ ) { var boxNum = ( n * 3 ) + m; var newDesignBox = document.createElement('div'); var newDesignBoxID = "design" + boxNum; newGalleryBox.appendChild(newDesignBox); newDesignBox.setAttribute('id',newDesignBoxID); newDesignBox.setAttribute('class',"designBox"); var newDesignImg = document.createElement('img'); var newDesignImgID = "designImg" + boxNum; newDesignImg.setAttribute('id',newDesignImgID); newDesignImg.setAttribute('class',"designImage"); newDesignImg.src = designImages[boxNum][0]; newDesignBox.appendChild(newDesignImg); } } } function squareOff(frame) { document.getElementById(frame.id).style.height = ((document.getElementById(frame.id).offsetWidth) * .33) + 'px'; } function setLinks() { for (x in designImages) { document.getElementById("design"+x).onclick = function(){ sendToURL(x) } }; } function sendToURL(x) { var url = designImages[x][1] MM_goToURL('self',url); return document.MM_returnValue; } function MM_goToURL() { //v3.0 var i, args=MM_goToURL.arguments; document.MM_returnValue = false; for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'"); } Code: window.onload = initForms; function initForms(){ for(var i=0; i<document.forms.length; i++){ document.forms[i].onsubmit = function(){ return validForm(); } } } Hi, this is the first part of a long code and I have three questions wondering if anyone could help me.. 1. What is the benifit of having the above code with "window.onload" and "for loop" and loop through the forms if I only have ONE form in html? 2. What is this line of code "document.forms[i].onsubmit" saying? Does it mean "Execute function() when submit button within form[i] has been pressed?" 3. function() - Does this empty function mean "run every following function below"?? Thank you!! 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? 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 ok so Code: document.write("Goodbye!"); works but I put ^ that inside a function Code: function SayHello () ( document.write("Goodbye!"); ) and it stops working? I know the function call works because when I place some code to display an image in SayHello function, it displays the image. Quote: <html> <head> <script type="text/javascript"> var a = january var b = febuary var c = march function test() { document.getElementById("test").innerHTML=a; <!-- needs to be A on first function click, b on second, c on third, etc..^^--> } </script> </head> <body> <p id="test"></p> <!-- the <p> should go to next month upon each function --> <input type="button" value="asdf" onclick="test()" /> </body> </html> I tried to explain it pretty well in the comment tags, thanks! I'm trying to get the following function working Code: function jump(document_root, mode, cat, id, qs) { var response = confirm("Are you sure that you want to completely delete this record"); if(response) { var url = document_root+"/"+mode+"/"+cat+"/"+id+qs; window.location(url); return true; } else return false; } It called with the following Code: <a href="" onclick="jump('/tradedoubler_admin/web', 'Pages', 'Delete', '011' ,'');">Delete</a> But the redirect isnt working i get the following error : Code: Error: uncaught exception: [Exception... "Cannot convert WrappedNative to function" nsresult: "0x8057000d (NS_ERROR_XPC_CANT_CONVERT_WN_TO_FUN)" location: "JS frame :: http://192.168.1.99/tradedoubler_admin/web/scripts/pagejump.js :: jump :: line 7" data: no] Is any one familiar with this error? It's suppose to be a pop up box that asks if the user really want to delete this record, if he clicks yes it redirects to delete it, but if not it doesn't do anything. Hello im having trouble with my onclick button specifically the "doall" is there a problem with my function or the button? Console says ReferenceError: doAll is not defined but I have set the function doAll so I don't get what's wrong. <!DOCTYPE html> <HTML> <HEAD><TITLE>Choice</TITLE> <meta content="text/html;charset=utf-8" http-equiv="Content-Type"> <meta content="utf-8" http-equiv="encoding"> <SCRIPT Language="javascript"> muresources="" muresources["classical"]= "<A HREF='http://net.com/classical.file1'>Meditative classical music<A><P> <A HREF='http://net.com/classical.file2'>Provoking classical music<A>" muresources["rock"] = "<A HREF='http://net.com/rock.file1'>Popular rock music<A><P> <A HREF='http://net.com/rock.file2'>Exciting rock music<A>" muresources["ethnic"] = "<A HREF='http://net.com/mexican.file1'>Mexican music<A><P> <A HREF='http://net.com/Indian.file2'>Indian music<A>" function getLink() { temp = muresources[choice] temp2 = "<TITLE>Custom Links</TITLE><H3>" +document.m.pername.value+", here are some links for you</H3><P>"+temp } function writeIt(){ diswin = window.open(); diswin.document.open(); diswin.document.write(temp2); diswin.document.close() } function doAll(){ getLink(); writeIt() } </SCRIPT> </HEAD> <BODY > <H3> Choose the kind of music you prefer<BR> and this page will fetch links of interest to you</H3> <HR> <FORM NAME="m" > Choose a kind of music<P> <INPUT TYPE="radio" NAME="mus" VALUE="classical" OnClick="choice='classical'" >Classical <BR> <INPUT TYPE="radio" NAME="mus" VALUE="rock" OnClick="choice='rock'">Rock<BR> <INPUT TYPE="radio" NAME="mus" VALUE="ethnic" OnClick="choice='ethnic'">Ethnic<BR> <HR> Please type your name<P> <INPUT TYPE="text" NAME="pername" SIZE=25> <HR> <INPUT TYPE="button" NAME="sub" VALUE="Show me links" OnClick=doAll()> <INPUT TYPE="reset" NAME="res" > </FORM> <SCRIPT> choice = "classical" document.m.mus[0].checked = true document.m.mus[1].checked = false document.m.mus[2].checked = false </SCRIPT> </BODY> </HTML> Hi, My webpage can work normally in IE but not in Safari(e.g. when I clicked on some buttons like 'Delete' button, the page opened in Safari stays the same while it should delete the object chosen). When I tried debugging on Safari, after clicking the 'update' button, this message error appeared: "TypeError: Result of expression 'this.form.fireEvent' [undefined] is not a function". I believe this code makes the incompatability between the 2 browser: Code: function DeleteClick() { var frmSWO = document.getElementById("form"); var answer = confirm("Do you really want to delete?") if (answer != 0) { frmSWO.action = "/domsWeb/mtd/doms/web/operation/eDepotMNR/controller/manageWorkOrder/DeleteJobOrImage.do"; frmSWO.method = "post"; this.form.fireEvent('onsubmit'); frmSWO.submit(); } } Any suggest how should I amend the script for it to work on 2 browser concurrently? Thanks all! Title basically says it. I need to get the object that was just clicked, to insert into a JavaScript function. I've tried "function('this')" and similar things, but it doesn't work. I'm sure this is REALLY easy to do, but I don't know it and I have no idea what to search for. Thanks Hi, I am a beginner in programming however I am close to completing this task for my uni course and I know what method is needed "toLowerCase()" yet I am not sure on where it needs to be placed. If i paste in the question and then the coding I have done so far any helped would be greatly appreciated. Thanks in advance to everyone who replies QUESTION: function findAnyU(s) - to discover if string s appears in any of the URLs in the array pages. Gives an alert of s together with 'found' or 'not found' as for find1C. [Note that the search should be case insensitive so that 'lboro' and 'Lboro' and 'LBORO' would all be found in 'www.lboro.ac.uk' - all remaining functions should also be case insensitive in this way] Example call: findAnyU("Lboro") Example result: "Lboro" found MY CODING... var pages = [ "[www.lboro.ac.uk] Loughborough University offers degree programmes and world class research.", "[www.XXXX.ac.uk] Loughborough University offers degree programmes and world class research. " ]; function findAnyU (s){ for(i=1;i<pages.length;i++) { var a = '"'+s+'"'; var b = pages[i].indexOf('['); var l = pages[i].indexOf(']'); var t = pages[i].substr(b+1, l); var c = t.indexOf(s); } if (c>=0) a+= ' found' else a+= ' not found' return (a) } alert(findAnyU("Lboro")); *********************************** Thanks Again Everyone X Code: <html> <body> var j=0; var temp,temp2,temp3; <script> function scor(j) { switch(j) { case 1: alert("Απαντήσατε σωστά μόνο σε μία ερώτηση.Προσπαθήστε πάλι"); break; case 2: alert("Απαντήσατε σωστά στις δύο από τις τρείς ερωτήσεις"); break; default: alert ("Συγχαρητήρια απαντήσατε σωστά και στις τρεις ερωτήσεις"); } } </script> <meta http-equiv="content-type" content="text/hmtl; charset=iso-8859-7"> <p align="center"><font size="5">Σε μία σελίδα html πόσα είναι τα μέγιστα frames που μπορούμε να τοποθετήσουμε; </p></font> <form name="for1"> <input type="radio" name="fr1"value="1" > 5 <br> <input type="radio" name="fr1"value="2" > Όσα τα pixels<br> <input type="radio" name="fr1"value="3" > Δεν υπάρχει όριο<br> <input type="button" value="Εκχώρηση Απάντησης" onClick="getVal1()"> </form> <script type = "text/javascript"> function getVal1() { for(var i=0; i<document.for1.fr1.length; i++) { if (document.for1.fr1[i].checked) { if (document.for1.fr1[i].value==2) { j++; } } } } function getVal2() { for (var i=0;i<document.for2.fr2.length;i++) { if (document.for2.fr2[i].checked) { if (document.for2.fr2[i].value==2) { j++; } } } } function getVal3() { for (var i=0;i<document.for3.fr3.length;i++) { if (document.for3.fr3[i].checked) { if (document.for3.fr3[i].value==3) { j++; } } } } </script> <p align="center"><font size="5"> Είναι απαραίτητο σε κάθε σελίδα html να υπάρχουν τα tags head και title;</p></font> <form name="for2"> <input type="radio" name="fr2" value="1"> Ναι <br> <input type="radio" name="fr2" value="2"> Όχι <br> <input type="button" value="Εκχώρηση Απάντησης" onClick="getVal2()"> </form> <p align="center"><font size="5"> Τι κάνει το εξής tag: meta http-equiv="content-type" content="text/hmtl; charset=iso-8859-7" </p></font> <form name="for3"> <input type ="radio" name="fr3" value="1"> Δημιουργεί τις προυποθέσεις για την απόκτηση τιμών <br> <input type ="radio" name="fr3" value="2"> Ισσοροπεί τις παραγράφους σε στήλες <br> <input type ="radio" name="fr3" value="3"> Επιτρέπει την κωδικοποίηση ελληνικών χαρακτήρων στην ιστοσελίδα <br> <input type="button" value="Εκχώρηση Απάντησης" onClick="getVal3()" </form> <input type ="button" value="Υπολογισμός" onClick="scor(j)"> Apart from any logical mistakes this thing i have created might have , my question is this.Why upon pressing the last button and calling the "scor(j)" function , no alerts pop up?Thanks in advance. I'm completely stumbled by this as i have no clue as what might be wrong.But then again , my experience is extremely limited |