JavaScript - Create Element("a") Problem
var newlink = document.createElement("a");
newlink.setAttribute("class", "mhs uiButton"); newlink.setAttribute("role", "button"); newlink.setAttribute("href", "http://www.facebook.com/#"); newlink.setAttribute("onlick","FriendBrowserCheckboxController.makeFriendRequest(this, '+javaedit.text+'); return false;"); alert(newlink.classname); why alert newlink.classname return as undefined ? i have set class = mhs uiButton already,should be return mhs uiButton? Similar TutorialsHi all, I've messing around with CSS and I would like to change the <body> 'class' when the user selects a hyperlink. To do this I've employed the OnClick method within the hyperlink which calls the function updateBodyClass(). Within upDateBodyClass() I would like to add the string "extraMenu" to the body class. Before selecting the hyperlink the body is: <body id="twoColLayout" class="tools"> I want this to change to: <body id="twoColLayout" class="tools extraMenu"> This is the code I currently have but it doesn't work. Please can someone point me in the right direction. Thankyou in advance for your time. <html> <head> <title>test</title> <meta http-equiv="Content-Script-Type" content="text/javascript"> <script> function updateBodyClass() { document.getElementById("body").className="tools"; document.getElementById("body").className+=" extraMenu" return; } </script> </head> <body id="twoColLayout" class="tools"> <a href="index.php" onClick="updateBodyClass()">Search Bookmarks</a> </body> </html> I was under the impression that you can always access any element on a webpage very easily by assigning a value to the "id" attribute. It seems this is true in the Chrome browser but not in the Opera Browser. My God I can't believe how much disarray the state of programming is in when it comes to certain things working in certain browsers...What's the HTML5 standard on this situation...in other words what does the ECMAScript standard say is the proper implementation? Code: <!DOCTYPE html> <html> <head> <title>Project 9-4</title> <script type="text/javascript"> /* <![CDATA[ */ function submitReservation() { var expirationDate = new Date(); expirationDate.setDate( expirationDate.getDate() + 1); document.cookie = "userFirstName=" + inputFirstName.value + "; expires=" + expirationDate.toUTCString(); document.cookie = "userLastName=" + inputLastName.value + "; expires=" + expirationDate.toUTCString(); document.cookie = "userStreet=" + inputStreet.value + "; expires=" + expirationDate.toUTCString(); document.cookie = "userCity=" + inputCity.value + "; expires=" + expirationDate.toUTCString(); document.cookie = "userState=" + inputState.value + "; expires=" + expirationDate.toUTCString(); document.cookie = "pickupDate=" + inputPickupDate.value + "; expires=" + expirationDate.toUTCString(); document.cookie = "returnDate=" + inputReturnDate.value + "; expires=" + expirationDate.toUTCString(); } function displayReservation() { if(!document.cookie) { window.alert("You don't have a reservation!"); return; } var allInputs = document.getElementsByTagName("input"); var crumbs = document.cookie.split("; "); var reservationInfo = "Reservation details: "; for(var i=0; i<crumbs.length; i++) if(allInputs[i].type=='text') { allInputs[i].value = crumbs[i].substring(crumbs[i].indexOf("=")+1, crumbs[i].length); reservationInfo += allInputs[i].value + ", "; } window.alert(reservationInfo); } /* ]]> */ </script> </head> <body> <h1>Hertz Rent-A-Car</h1> <form action="" method="get"> First name: <input type="text" id="inputFirstName" size="16" maxlength="32" /> Last name: <input type="text" id="inputLastName" size="16" maxlength="32" /> <fieldset> <legend>Address<legend> Street : <input type="text" id="inputStreet" size="16" maxlength="32" /> City: <input type="text" id="inputCity" size="16" maxlength="32" /> State: <input type="text" id="inputState" size="16" maxstring="32" /> </fieldset> Pickup date: <input type="date" id="inputPickupDate" name="inputPickupDate" /> Return date: <input type="date" id="inputReturnDate" /> <input type="button" id="buttonSubmit" value="Submit Reservation" onclick="submitReservation();" /> <input type="button" id="buttonDisplay" value="Show Reservation" onclick="displayReservation();" /> </form> </body> </html> Should you be able to access any webpage element by simply specifying the value of it's 'id' attribute? Chrome says 'yes'. Opera says 'no can do'. I get a 'Uncaught Exception;ReferenceError:Undefined variable' error message in the Opera debugger window. The exact same .html document throws no exceptions in the Chrome(version 18) browser. 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 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! this is not the first time i have run into a situation that has caused me to go "i wish there was some 'onload' event for this div#products so i can execute renderProducts() without waiting for the page to load completely" i dont want to wait for the DOMContentLoaded event, because that causes an annoying restyling of whatever modifications are made by script after the parent containers have already been rendered. it seems like there is no good solution to this so i decided to resort to using inline scripts. eg: Code: <div id="products"> <div id="product_tpl" class="tmplt" style="display:none;"> <h3>{product.name}</h3> <img src="/images/{product.sku}_main.jpg" /><br /> <p>{product.name}</p> </div> <script type="text/javascript">renderProducts()</script> </div> renderProducts() uses an existing javascript object array and fills the div with products using the product template. this way the content is filled and rendered instantly, using the same js function-call that will fill that div for AJAX actions like pagination, filtering, etc. i'm not sure of a better way to do it without having to physically write backend code to replicate the rendering logic. i know that i can just return html from the server for this and ajax calls, but this way i just return data from the server in JSON and let the server take care of the business logic only..more of a web-service model. any input would be appreciated. thanks, Leon I have this code in a .js file: <code> function addElement() { addbranch(); } function IfElseActivity(element) { this.element = element var innerBar=document.createElement("DIV") innerBar.className="bar" innerBar.style["width"]=100+"%" innerBar.style["heigth"]=28+"px" //innerBar.innerHTML = "<p>"+item.id+"</p>" innerBar.innerHTML = "<DIV id='"+element.id+"_id' class='idlabel'>"+element.id+"</DIV>" element.appendChild(innerBar) this.group = Quanticks.drag().createSimpleActivity(element, innerBar) this.Branches = new Array() this.Properties = new Array() this.ActWidth = 360 this.BlockWidth = 160 this.noResizeFlag = false this.noBranchResizeFlag = false } IfElseActivity.GetToolboxIcon = function() { return "/images/ifelse.GIF"; } IfElseActivity.prototype = { Initialize : function() { this.header = document.createElement("img") this.header.src = "images/ifelsehead.GIF" this.header.setAttribute("width", "268"); this.header.setAttribute("height", "49"); this.header.onclick = function() {addElement();}; this.element.appendChild(this.header) this.table = document.createElement("table") this.tablebody = document.createElement("tbody") this.tablerow = document.createElement("tr") this.tablebody.appendChild(this.tablerow) this.table.appendChild(this.tablebody) this.element.appendChild(this.table) this.table.setAttribute("border", "0"); this.addBranch() this.addBranch() this.footer = document.createElement("img") this.footer.src = "images/ifelsefoot.GIF" this.footer.setAttribute("width", "268"); this.footer.setAttribute("height", "49"); this.element.appendChild(this.footer) }, addBranch : function() { var cell = document.createElement("td"); var branch=document.createElement("DIV") branch.className="SequenceActivity" var branchConnector=document.createElement("DIV") branchConnector.className="connector" var innerImg=document.createElement("IMG") innerImg.src="images/connector.gif" branchConnector.appendChild(innerImg) connectors[connectors.length] = branchConnector branch.appendChild(branchConnector) cell.appendChild(branch) this.tablerow.appendChild(cell) cell.setAttribute("vAlign","top") branch.onresize=BranchResize branch.name = getNewId("IfElseBranchActivity"); this.Branches[this.Branches.length] = branch return branch; }, </code> This code creates a kind of ifelse figure on a page with two braches. This works. However, when "this.header.onclick" is clicked an extra branche must be added. Obviously my function does not work. Is the a way to get this working? I would really like to use the original addbranch function 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> Hi pals, I am really tired in this problem of event keyup. I given same in my keyup function like: $(document).ready(function () { alert("GGG"+parseInt(jQuery.browser.version)); //To display test value working $("#find_text").keyup(function(e) { if(e.which == 13) { alert('Enter key was pressed'); //enter Here alert("FFF"+parseInt(jQuery.browser.version)); //Here got Error } }); }); I got Error : jQuery is not defined alert("FFF"+parseInt(jQuery.browser.version)); I use keycode,which , but no help, It's Work nicely in Chrome Browser but not in FF. Please give a Solution reply ASAP, I am really Tired.The code enter the Condition But that jQuery part make error. Thankfully Anes P.A This script works great for populating predefined lists of data into a textarea as selected by the user using a radio button: Code: <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Populate Textarea Based on Radio Button Selection</title> <script> text = new Array() text[0] = Array('Hotel', 'Motel'); text[1] = Array('Couch', 'Bed', 'Chair'); function populate(r,f){ t=-1; for(var i=0;i<f.elements[r].length;i++){ if (f.elements[r][i].checked){ var t=i; } } if(t>-1){ f.thefirsttextarea.value= text[t].toString().replace(/,/gi,"\n"); } } </script> </head> <body> <form name="frm"> <input type="radio" name="test" value="0" onClick="populate(this.name,this.form)"> <input type="radio" name="test" value="1" onClick="populate(this.name,this.form)"> <textarea name="thefirsttextarea"></textarea> <input type="submit" value="submit" /> </form> </body> </html> However, I've coded all night only to come across an issue. I have an inline page style which calls/includes multiple pages. Two of these pages require this feature. It seems one is canceling out the other. Here's an example: Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Populate Multiple Textareas Based on Radio Button Selection</title> <script> text = new Array() text[0] = Array('Hotel', 'Motel'); text[1] = Array('Couch', 'Bed', 'Chair'); function populate(r,f){ t=-1; for(var i=0;i<f.elements[r].length;i++){ if (f.elements[r][i].checked){ var t=i; } } if(t>-1){ f.thefirsttextarea.value= text[t].toString().replace(/,/gi,"\n"); } } </script> <script> textt = new Array() <!--default--> text[0] = Array('Ham', 'Turkey', 'Chicken'); <!--all--> text[1] = Array('Beer', 'Soda', 'Water'); <!--johnny havana--> text[2] = Array('Milk', 'Cheese', 'Butter'); function populate(r,f){ t=-1; for(var i=0;i<f.elements[r].length;i++){ if (f.elements[r][i].checked){ var t=i; } } if(t>-1){ f.SECONDFORM.value= text[t].toString().replace(/,/gi,"\n"); } } </script> </head> <body> <form name="form"> <input type="radio" name="test" value="0" onClick="populate(this.name,this.form)"> <input type="radio" name="test" value="1" onClick="populate(this.name,this.form)"> <textarea name="thefirsttextarea"></textarea> <input type="submit" value="submit" /> </form> <form name="anotherform"> <input type="radio" name="anothertest" value="0" onClick="populate(this.name,this.form)"> <input type="radio" name="anothertest" value="1" onClick="populate(this.name,this.form)"> <textarea name="SECONDFORM"></textarea> <input type="submit" value="submit" /> </form> </body> </html> With the above code only the second set of radio buttons work. What I need help with is a way to have two independent sets of arrays the correspond correctly with the textareas - One set that populates textarea 1 and the other that populates textarea 2. I am running on Magento eCommerce, however please don't turn away if you have no experience with it. Problem is with JavaScript. When one clicks on the button, nothing happens, when the page loads browsers in general display error message, that 'productAddtoCartForm' is null or not an object Here's the piece of code around the Add button: Code: <div class="product-view"> <div class="product-essential"> <form action="http://myhairpalace.com/index.php/default/checkout/cart/add/uenc/aHR0cDovL215aGFpcnBhbGFjZS5jb20vaW5kZXgucGhwL2RlZmF1bHQvaW5kaWFuLXJlbXktZnJvbnQvMTAwLWh1bWFuLWhhaXItbGFjZS1mcm9udC13aWctc3V6aWUuaHRtbD9fX19TSUQ9VQ,,/product/57/" method="post" id="product_addtocart_form" enctype="multipart/form-data"> <div class="no-display"> <input type="hidden" name="product" value="57� /> <input type=" hidden"="" id="related-products-field" product-shop"=""> <div class="product-name"> <h1>100% Human Hair Lace Front Wig-Suzie</h1> </div> <p class="email-friend"><a href="http://myhairpalace.com/index.php/default/sendfriend/product/send/id/57/cat_id/11/">Email to a Friend</a></p> <p class="no-rating"><a href="http://myhairpalace.com/index.php/default/review/product/list/id/57/category/11/#review-form">Be the first to review this product</a></p> <p class="availability in-stock">Availability: <span>In stock</span></p> <div class="price-box"> <span class="regular-price" id="product-price-57"> <span class="price">$75.00</span> </span> </div> <ul class="add-to-links"> <li><a href="http://myhairpalace.com/index.php/default/wishlist/index/add/product/57/" class="link-wishlist">Add to Wishlist</a></li> <li><span class="separator">|</span> <a href="http://myhairpalace.com/index.php/default/catalog/product_compare/add/product/57/uenc/aHR0cDovL215aGFpcnBhbGFjZS5jb20vaW5kZXgucGhwL2RlZmF1bHQvaW5kaWFuLXJlbXktZnJvbnQvMTAwLWh1bWFuLWhhaXItbGFjZS1mcm9udC13aWctc3V6aWUuaHRtbD9fX19TSUQ9VQ,,/" class="link-compare">Add to Compare</a></li> </ul> <div class="short-description"> <h2>Quick Overview</h2> <div class="std">Suzie</div> </div> </div> <div class="product-img-box"> <p class="product-image product-image-zoom"> <img id="image" src="http://myhairpalace.com/media/catalog/product/cache/1/image/9df78eab33525d08d6e5fb8d27136e95/l/a/lace_front-shan.jpg" alt="100% Human Hair Lace Front Wig-Suzie" title="100% Human Hair Lace Front Wig-Suzie"></p> <p class="zoom-notice" id="track_hint">Double click on above image to view full picture</p> <div class="zoom"> <img id="zoom_out" src="http://myhairpalace.com/skin/frontend/default/default/images/slider_btn_zoom_out.gif" alt="Zoom Out" title="Zoom Out" class="btn-zoom-out"> <div id="track"> <div id="handle"></div> </div> <img id="zoom_in" src="http://myhairpalace.com/skin/frontend/default/default/images/slider_btn_zoom_in.gif" alt="Zoom In" title="Zoom In" class="btn-zoom-in"> </div> <script type="text/javascript"> //<![CDATA[ Event.observe(window, 'load', function() { product_zoom = new Product.Zoom('image', 'track', 'handle', 'zoom_in', 'zoom_out', 'track_hint'); }); //]]> </script> <div class="more-views"> <h2>More Views</h2> <ul> <li> <a href="#" onclick="popWin('http://myhairpalace.com/index.php/default/catalog/product/gallery/id/57/image/56/', 'gallery', 'width=300,height=300,left=0,top=0,location=no,status=yes,scrollbars=yes,resizable=yes'); return false;" title=""><img src="http://myhairpalace.com/media/catalog/product/cache/1/thumbnail/56x/9df78eab33525d08d6e5fb8d27136e95/l/a/lace_front-shan.jpg" width="56" height="56" alt=""></a> </li> </ul> </div> </div> <div class="clearer"></div> <div class="product-options" id="product-options-wrapper"> <script type="text/javascript"> //<![CDATA[ var DateOption = Class.create({ getDaysInMonth: function(month, year) { var curDate = new Date(); if (!month) { month = curDate.getMonth(); } if (2 == month && !year) { // leap year assumption for unknown year return 29; } if (!year) { year = curDate.getFullYear(); } return 32 - new Date(year, month - 1, 32).getDate(); }, reloadMonth: function(event) { var selectEl = event.findElement(); var idParts = selectEl.id.split("_"); if (idParts.length != 3) { return false; } var optionIdPrefix = idParts[0] + "_" + idParts[1]; var month = parseInt($(optionIdPrefix + "_month").value); var year = parseInt($(optionIdPrefix + "_year").value); var dayEl = $(optionIdPrefix + "_day"); var days = this.getDaysInMonth(month, year); //remove days for (var i = dayEl.options.length - 1; i >= 0; i--) { if (dayEl.options[i].value > days) { dayEl.remove(dayEl.options[i].index); } } // add days var lastDay = parseInt(dayEl.options[dayEl.options.length-1].value); for (i = lastDay + 1; i <= days; i++) { this.addOption(dayEl, i, i); } }, addOption: function(select, text, value) { var option = document.createElement('OPTION'); option.value = value; option.text = text; if (select.options.add) { select.options.add(option); } else { select.appendChild(option); } } }); var dateOption = new DateOption(); //]]> </script> <script type="text/javascript"> //<![CDATA[ var optionFileUpload = { productForm : $('product_addtocart_form'), formAction : '', formElements : {}, upload : function(element){ this.formElements = this.productForm.select('input', 'select', 'textarea', 'button'); this.removeRequire(element.readAttribute('id').sub('option_', '')); template = '<iframe id="upload_target" name="upload_target" style="width:0; height:0; border:0;"><\/iframe>'; Element.insert($('option_'+element.readAttribute('id').sub('option_', '')+'_uploaded_file'), {after: template}); this.formAction = this.productForm.action; var baseUrl = 'http://myhairpalace.com/index.php/default/catalog/product/upload/'; var urlExt = 'option_id/'+element.readAttribute('id').sub('option_', ''); this.productForm.action = parseSidUrl(baseUrl, urlExt); this.productForm.target = 'upload_target'; this.productForm.submit(); this.productForm.target = ''; this.productForm.action = this.formAction; }, removeRequire : function(skipElementId){ for(var i=0; i<this.formElements.length; i++){ if (this.formElements[i].readAttribute('id') != 'option_'+skipElementId+'_file' && this.formElements[i].type != 'button') { this.formElements[i].disabled='disabled'; } } }, addRequire : function(skipElementId){ for(var i=0; i<this.formElements.length; i++){ if (this.formElements[i].readAttribute('name') != 'options_'+skipElementId+'_file' && this.formElements[i].type != 'button') { this.formElements[i].disabled=''; } } }, uploadCallback : function(data){ this.addRequire(data.optionId); $('upload_target').remove(); if (data.error) { } else { $('option_'+data.optionId+'_uploaded_file').value = data.fileName; $('option_'+data.optionId+'_file').value = ''; $('option_'+data.optionId+'_file').hide(); $('option_'+data.optionId+'').hide(); template = '<div id="option_'+data.optionId+'_file_box"><a href="#"><img src="var/options/'+data.fileName+'" alt=""><\/a><a href="#" onclick="optionFileUpload.removeFile('+data.optionId+')" title="Remove file" \/>Remove file<\/a>'; Element.insert($('option_'+data.optionId+'_uploaded_file'), {after: template}); } }, removeFile : function(optionId) { $('option_'+optionId+'_uploaded_file').value= ''; $('option_'+optionId+'_file').show(); $('option_'+optionId+'').show(); $('option_'+optionId+'_file_box').remove(); } } var optionTextCounter = { count : function(field,cntfield,maxlimit){ if (field.value.length > maxlimit){ field.value = field.value.substring(0, maxlimit); } else { cntfield.innerHTML = maxlimit - field.value.length; } } } Product.Options = Class.create(); Product.Options.prototype = { initialize : function(config){ this.config = config; this.reloadPrice(); }, reloadPrice : function(){ price = new Number(); config = this.config; skipIds = []; $$('.product-custom-option').each(function(element){ var optionId = 0; element.name.sub(/[0-9]+/, function(match){ optionId = match[0]; }); if (this.config[optionId]) { if (element.type == 'checkbox' || element.type == 'radio') { if (element.checked) { if (config[optionId][element.getValue()]) { price += parseFloat(config[optionId][element.getValue()]); } } } else if(element.hasClassName('datetime-picker') && !skipIds.include(optionId)) { dateSelected = true; $$('.product-custom-option[id^="options_' + optionId + '"]').each(function(dt){ if (dt.getValue() == '') { dateSelected = false; } }); if (dateSelected) { price += parseFloat(this.config[optionId]); skipIds[optionId] = optionId; } } else if(element.type == 'select-one' || element.type == 'select-multiple') { if (element.options) { $A(element.options).each(function(selectOption){ if (selectOption.selected) { if (this.config[optionId][selectOption.value]) { price += parseFloat(this.config[optionId][selectOption.value]); } } }); } } else { if (element.getValue().strip() != '') { price += parseFloat(this.config[optionId]); } } } }); try { optionsPrice.changePrice('options', price); optionsPrice.reload(); } catch (e) { } } } function validateOptionsCallback(elmId, result){ var container = $(elmId).up('ul.options-list'); if (result == 'failed') { container.removeClassName('validation-passed'); container.addClassName('validation-failed'); } else { container.removeClassName('validation-failed'); container.addClassName('validation-passed'); } } var opConfig = new Product.Options({"80":{"447":0,"448":0,"451":0,"452":0,"449":0,"450":0,"454":0,"453":0}}); //]]> </script> <dl> <dt><label>Color<span class="required"> *</span></label></dt> <dd class="last"> <select name="options[80]" id="select_80" class=" required-entry product-custom-option" title="" onchange="opConfig.reloadPrice()"><option value="">-- Please Select --</option><option value="447">1 </option><option value="448">1B </option><option value="451">1B/30 </option><option value="452">1B/33 </option><option value="449">2 </option><option value="450">4 </option><option value="454">4/27 </option><option value="453">4/30 </option></select> </dd> </dl> <script type="text/javascript"> //<![CDATA[ enUS = {"m":{"wide":["January","February","March","April","May","June","July","August","September","October","November","December"],"abbr":["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]}}; // en_US locale reference Calendar._DN = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]; // full day names Calendar._SDN = ["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]; // short day names Calendar._FD = 0; // First day of the week. "0" means display Sunday first, "1" means display Monday first, etc. Calendar._MN = ["January","February","March","April","May","June","July","August","September","October","November","December"]; // full month names Calendar._SMN = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]; // short month names Calendar._am = "AM"; // am/pm Calendar._pm = "PM"; // tooltips Calendar._TT = {}; Calendar._TT["INFO"] = "About the calendar"; Calendar._TT["ABOUT"] = "DHTML Date/Time Selector\n" + "(c) dynarch.com 2002-2005 / Author: Mihai Bazon\n" + "For latest version visit: http://www.dynarch.com/projects/calendar/\n" + "Distributed under GNU LGPL. See http://gnu.org/licenses/lgpl.html for details." + "\n\n" + "Date selection:\n" + "- Use the \xab, \xbb buttons to select year\n" + "- Use the " + String.fromCharCode(0x2039) + ", " + String.fromCharCode(0x203a) + " buttons to select month\n" + "- Hold mouse button on any of the above buttons for faster selection."; Calendar._TT["ABOUT_TIME"] = "\n\n" + "Time selection:\n" + "- Click on any of the time parts to increase it\n" + "- or Shift-click to decrease it\n" + "- or click and drag for faster selection."; Calendar._TT["PREV_YEAR"] = "Prev. year (hold for menu)"; Calendar._TT["PREV_MONTH"] = "Prev. month (hold for menu)"; Calendar._TT["GO_TODAY"] = "Go Today"; Calendar._TT["NEXT_MONTH"] = "Next month (hold for menu)"; Calendar._TT["NEXT_YEAR"] = "Next year (hold for menu)"; Calendar._TT["SEL_DATE"] = "Select date"; Calendar._TT["DRAG_TO_MOVE"] = "Drag to move"; Calendar._TT["PART_TODAY"] = ' (' + "Today" + ')'; // the following is to inform that "%s" is to be the first day of week Calendar._TT["DAY_FIRST"] = "Display %s first"; // This may be locale-dependent. It specifies the week-end days, as an array // of comma-separated numbers. The numbers are from 0 to 6: 0 means Sunday, 1 // means Monday, etc. Calendar._TT["WEEKEND"] = "0,6"; Calendar._TT["CLOSE"] = "Close"; Calendar._TT["TODAY"] = "Today"; Calendar._TT["TIME_PART"] = "(Shift-)Click or drag to change value"; // date formats Calendar._TT["DEF_DATE_FORMAT"] = "%b %e, %Y"; Calendar._TT["TT_DATE_FORMAT"] = "%B %e, %Y"; Calendar._TT["WK"] = "Week"; Calendar._TT["TIME"] = "Time:"; //]]> </script> <p class="required">* Required Fields</p> </div> <script type="text/javascript">decorateGeneric($$('#product-options-wrapper dl'), ['last']);</script> <div class="product-options-bottom"> <div class="price-box"> <span class="regular-price" id="product-price-57_clone"> <span class="price">$75.00</span> </span> </div> <div class="add-to-cart"> <label for="qty">Qty:</label> <input type="text" name="qty" id="qty" maxlength="12" value="1" title="Qty" class="input-text qty"> <button type="button" title="Add to Cart" class="button btn-cart" onclick="productAddToCartForm.submit()"><span><span>Add to Cart</span></span></button> <p class="paypal-logo"><a id="ec_shortcut_c2e3fb1be4b9e9d53800cbc4d5f1e274" href="http://myhairpalace.com/index.php/default/paypal/express/start/"> <img src="https://fpdbs.paypal.com/dynamicimageweb?cmd=_dynamic-image&buttontype=ecshortcut&locale=en_US" alt="Checkout with PayPal"> </a> <input type="hidden" id="pp_checkout_url" name="return_url" value=""> <script type="text/javascript"> //<![CDATA[ Event.observe('ec_shortcut_c2e3fb1be4b9e9d53800cbc4d5f1e274', 'click', function(event) { $('pp_checkout_url').value = this.href; productAddToCartForm.submit(); event.stop(); }); //]]> </script></p> </div> </div> </form> <script type="text/javascript"> //<![CDATA[ var productAddToCartForm = new VarienForm('product_addtocart_form'); productAddToCartForm.submit = function(){ if (this.validator.validate()) { this.form.submit(); } }.bind(productAddToCartForm); //]]> </script> </div> <div class="product-collateral"> <div class="box-collateral box-description"> <h2>Details</h2> <div class="std"> Nautral Hairline 100% Human Hair Lace Front wig. </div> </div> <div class="box-collateral box-tags"> <h2>Product Tags</h2> <form id="addTagForm" action="http://myhairpalace.com/index.php/default/tag/index/save/product/57/uenc/aHR0cDovL215aGFpcnBhbGFjZS5jb20vaW5kZXgucGhwL2RlZmF1bHQvaW5kaWFuLXJlbXktZnJvbnQvMTAwLWh1bWFuLWhhaXItbGFjZS1mcm9udC13aWctc3V6aWUuaHRtbD9fX19TSUQ9VQ,,/" method="get"> <div class="form-add"> <label for="productTagName">Add Your Tags:</label> <div class="input-box"> <input type="text" class="input-text required-entry" name="productTagName" id="productTagName"> </div> <button type="button" title="Add Tags" class="button" onclick="submitTagForm()"> <span> <span>Add Tags</span> </span> </button> </div> </form> <p class="note">Use spaces to separate tags. Use single quotes (') for phrases.</p> <script type="text/javascript"> //<![CDATA[ var addTagFormJs = new VarienForm('addTagForm'); function submitTagForm(){ if(addTagFormJs.validator.validate()) { addTagFormJs.form.submit(); } } //]]> </script> </div> </div> </div> Magento uses Prototype framework and the problem has something to do with prototype.js file and indeed, when I debugged in Chrome, here's what came up: Now, the crux is that the error shows up only pages featuring products w/ options in dropdown menus: http://myhairpalace.com/index.php/de...inkerbell.html You are able to add Simple Products to cart just fine: http://myhairpalace.com/index.php/de...o-measure.html I would be incredibly grateful for ANY suggestions. 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> . 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? . All, So I have the following code. It works great. When I add this: Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> It doesn't work. I need it for some aspects of my CSS to work. The code that works without that is: Code: <html> <script> function resizeAll( ) { var divs = document.getElementsByTagName("div"); for ( var d = 0; d < divs.length; ++d ) { var div = divs[d]; if ( div.className == "fn-area" ) { divid = divs[d].getAttribute("id"); imgid = "Img" + divid; var Div1Width, Div1Height; Div1Width = document.getElementById(divid).offsetWidth; Div1Height = document.getElementById(divid).offsetHeight; document.getElementById(imgid).style.width = Div1Width; document.getElementById(imgid).style.height = Div1Height; } } } </script> <head> </head> <body onLoad="resizeAll()"> <div id="Div1" class="fn-area" style="width:100px;height:100px; border:1px solid black;" onmouseover="document.getElementById('ImgDiv1').style.display='block';" onmouseout="document.getElementById('ImgDiv1').style.display='none';"> <img id="ImgDiv1" src="fnclientlib/styles/artwork/creep_stamp5.gif" style="display:none"/> </div> <div id="Div2" class="fn-area" style="width:300px;height:300px; border:1px solid black;" onmouseover="document.getElementById('ImgDiv2').style.display='block';" onmouseout="document.getElementById('ImgDiv2').style.display='none';"> <img id="ImgDiv2" src="fnclientlib/styles/artwork/creep_stamp5.gif" style="display:none"/> </div> </body </html> Ok so i was trying to get a script to run on button click, when i clicked the button the code ran but i a white screened tab. Additinal info - when I ran my script on page load it worked perfectly. Here is the ccode i'm trying to run Code: <script type = "text/javascript"> function runMyJavascript_Caught() { // get user to add name var name_entry = prompt ("Please Enter your Name!", "James"); // declare some short strings var stating = ", I knew you did it!"; var told = "I told you that I would find out"; var mistake = "I guess you just made a mistake entering your name, "; var punish = "Now go back to your room"; var heading = "OI Stop"; // construct some longer strings var stating_name = name_entry + stating; var mistake_name = mistake + name_entry; document.writeln(heading.bold() + "<br>"); document.writeln(stating_name + "<br>"); document.writeln(told + "<br>"); document.writeln(mistake_name + "<br>"); document.writeln(punish + "<br>"); } </script> |