JavaScript - Javascript Onload Function
Hi
I am new to javascript and designing websites as a whole. I have been playing around with a drag and drop java script from this site: http://www.redips.net/javascript/dra...table-content/ A switch content setting is currently available to check in a checklist: <input name="drop_option" type="radio" class="checkbox" title="Switch content" onclick="set_drop_option(this)" value="switch"/> I wan it to run without any checklist or button whatsoever just from the page load. I am not sure how I would do this. Any suggestions? Thank you Jonathan Similar TutorialsI have the following javascript function: [ function addNewWindowEvent(evType, fn) { if (window.addEventListener) { this.addEventListener("load", fn, false); return true; } else if (window.attachEvent) { var onload = "onload" this.attachEvent(onload, fn); return true; } else { return false; } } ] which is giving me a an exception every time a page on our site loads. The actual exception in firefox is this: uncaught exception: [Exception... "Could not convert JavaScript argument" nsresult: "0x80570009 (NS_ERROR_XPC_BAD_CONVERT_JS)" location: "JS frame :: https://cms-dev.stchas.edu/global/js/hdvscripts.js :: addNewWindowEvent :: line 5" data: no] and I'm not sure exactly what it's complaining about. I'm relatively new to javascript so diagnosing and fixing this problem has me quite puzzled, and so far I have been unable to find anything helpful when I try and google for information on this. I would appreciate any help or suggestions. Thanks. henryv Hello Can anyone help with the following problem On the following page http://www.stroudskittles.co.uk/signingon.html I have a Body onload event (to load the chained Menu) and a windows.onload event (to load the IFrame Ticker) If I open the page in Internet explorer both scripts function; however in Firefox I'm having problems. The Chained Menu works, however the IFrame Ticker does not display. Both events ahave ben placed on the boady tag. Can anyone advise how I can get both to display in Firefox Can anyone I have a popup window that calls a texteditor. I want the texteditor to show the inner HTML of the parent doucument by div id. When I call the function through a submit (in child window) it workks great, but I want innerHTML to be added when child page loads. I have tried calling function in body onLoad=getparent; tries adding it to inner script where it calls the editor , again onLoad=getparent; Tried with and without () i.e onLoad=getparent(); Child window code: [code] <html> <head> <title>Mangae Content</title> <script type="text/javascript" src="/ckeditor/ckeditor.js"></script> <script language="javascript"> function getparent() { var TextToPass = window.opener.document.getElementById('missionStatement'); var TextToEdit = TextToPass.innerHTML; document.getElementById('editor1').value=TextToEdit; } </script> </head> <body> <form method="post" name="editedcontent"> <p> My Editor:<br /> <textarea name="editor1" id="editor1"></textarea> <script type="text/javascript"> onload=getparent; CKEDITOR.replace( 'editor1' ); </script> </p> <p> <input type="submit" onClick="getparent();"/> </p> </form> </body> </html> [code] When I use the submit button it works fine. Captures parent window HTML and loads it into ckeditor, How do I get it to load without using the submit button??? Any help would be greatly appreciated. I'm trying to get a select box to populate onload but can't get it to go. It works fine onchange. This populates the city select box from my db depending on what state is selected. Here are the functions: Code: function handleOnChange(dd1) { var idx = dd1.selectedIndex; var val = dd1[idx].text; var par = document.forms["cbcheckedadminForm", "adminForm"]; var parelmts = par.elements; var cb_citysel = parelmts["cb_city"]; var state = val; var directory = ""+document.location; directory = directory.substr(0, directory.lastIndexOf('/')); Http.get({ url: "./components/com_helloworld/js/regvalues/" + state + ".php", callback: fillcb_city, cache: Http.Cache.Get }, [cb_citysel]); } function fillcb_city(xmlreply, cb_cityelmt) { if (xmlreply.status == Http.Status.OK) { var cb_cityresponse = xmlreply.responseText; var cb_cityar = cb_cityresponse.split("|"); cb_cityelmt.length = 1; cb_cityelmt.length = cb_cityar.length; for (o=1; o < cb_cityar.length; o++) { cb_cityelmt[o].text = cb_cityar[o]; } } else { alert("Cannot handle the Ajax call."); } } And here's how I'm trying to do the onload: Code: function addLoadEvent(func) { var oldonload = window.onload; if (typeof window.onload != 'function') { window.onload = func; } else { window.onload = function() { if (oldonload) { oldonload(); } func(); } } } addLoadEvent(function() { ajaxFunction(document.getElementById('country').value); }); addLoadEvent(function() { setupDependencies('cbcheckedadminForm', 'adminForm', 'locationsearch'); }); addLoadEvent(function() { handleOnChange(dd1); }); addLoadEvent(function() { fillcb_city(xmlreply, cb_cityelmt); }); I've tried variations of handleOnChange(cb_state), handleOnChange(document.getElementById('cb_state'), handleOnChange(ydntuwrkupceofcrp), I've tried chaining the 2 functions together, but nothing I do seems to get this to work. What am I missing here? I am relatively new to JavaScript so am still learning. I have a page I would like to call a function when it loads but not sure how to do this. The function is http://tickettransaction.com/?bid=20...ults&venid=101 and should function similar to this page when loads http://paviliondallas.com/ I could get that with html but not sure how to auto load to render ths list from the provided plugin. Another example is http://www.justbuytickets.com/Venues...FcY32godDU-hzw Any help would be appreciated. Thanks in advance. Hey guys I am having trouble loading a drop down menu list script that I got from Dynamic Drive. Here's the original test page. (Works Fine) <html> <head> <script language="javascript" src="http://www.modbargains.com/images/Javascript/ChainSel/chainedmenu.js"> </script> <script language="javascript" src="http://www.modbargains.com/images/Javascript/ChainSel/MBVehicleChainSelect.js"></script> </head> <body onLoad="initListGroup('Vehicles', document.listmenu0.firstlevel, document.listmenu0.secondlevel, document.listmenu0.thirdlevel, 'savestate')"> <form name="listmenu0"> <table align="center"> <tr> <td><select name="firstlevel" style="width:160px;"></select></td> </tr> <tr> <td><select name="secondlevel" style="width:160px;"></select></td> </tr> <tr> <td><select name="thirdlevel" style="width:160px;"></select></td> </tr> <tr> <td><input type="button" value="Go" onClick="goListGroup(document.listmenu0.firstlevel, document.listmenu0.secondlevel, document.listmenu0.thirdlevel)"> <input type="button" value="Reset" onClick="resetListGroup('Vehicles')"> </tr> </table> </form> </body> </html> HOWEVER! The site I am working on (which is on a different server) does not allow me to alternate the body tag. Is there an alternative way of doing a body onLoad without actually alternating the body tag? I read that you could do a function onload using javascript, so I tried using this: <script language="javascript" > window.onload = initListGroup('Vehicles', document.listmenu0.firstlevel, document.listmenu0.secondlevel, document.listmenu0.thirdlevel, 'savestate'); </script> I am not sure if the function is correct but it does not work. Any ideas how I can make this work???? I don't get to use javascript as much as I would like, but I am having a problem with a page so I stripped out all the extras and got down to just the part I am having a problem with and I think this should fill the div with the id testingdiv when the page loads but it doesn't. Any help would be appreciated. Code: <script type="text/javascript"> function getClientList(listtype) { document.getElementById('testingdiv').innerHTML = listtype; } window.onload = getClientList('own'); </script> <!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" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <input type="hidden" name="hidden" id="hidden" value="99" /> <title>untitled</title> </head> <body> <div id="testingdiv"></div> </body> </html> 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>Untitled Document</title> <script> window.onload = function(){h = parseInt(document.getElementById( "div1" ).style.height);} var t; function addHeight(openAccordionID){ clearInterval(t); document.getElementById(openAccordionID).style.height = h+"px"; h+=1; t = setInterval("addHeight('"+openAccordionID+"')",10); for(var x=1; x<h; x++) if(h%(x*100)==0){clearInterval(t);} } </script> </head> <body> <div id="div1" onclick="addHeight(this.id)" style="width: 200px; height: 20px; background-color: yellow;">Increase Height</div> </body> </html> How can I still use the parameter "openAccordionID" in the blue-highlighted part? I tried, but it failed. Hi, I am trying to get a javascript if else function to initiate during the page onload. In IE the if command doesn't work if I add an else command (the command shown though the session value is set to comply with the if command). While when using Firefox neither works. Any help would be fantastic. Code: <?php session_start(); $_SESSION['ID']='x'; ?> <html> <head> <script type="text/javascript"> if ($_SESSION['ID']=='x'){ function loadXMLDoc() { if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("myDiv").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","ajax_info.txt",true); xmlhttp.send(); } } else{ function loadXMLDoc() { if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("myDiv").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","ajax_mine.txt",true); xmlhttp.send(); } } </script> </head> <body onload="loadXMLDoc()"> <div id="myDiv"><h2>Page Loading</h2></div> </body> </html> The ajax_info.txt file and the ajax_mine.txt file both show basic information only. Hi, I need to use more than one javascripts that use onload event. Every time I try this only one from these scripts work correctly. How can I make these scripts work together? 1) Code: var kmrSimpleTabs = { sbContainerClass: "simpleTabs", sbNavClass: "simpleTabsNavigation", sbContentClass: "simpleTabsContent", sbCurrentNavClass: "current", sbCurrentTabClass: "currentTab", sbIdPrefix: "tabber", init: function(){ if(!document.getElementsByTagName) return false; if(!document.getElementById) return false; var containerDiv = document.getElementsByTagName("div"); for(var i=0; i<containerDiv.length; i++){ if (containerDiv[i].className == kmrSimpleTabs.sbContainerClass) { // assign a unique ID for this tab block and then grab it containerDiv[i].setAttribute("id",kmrSimpleTabs.sbIdPrefix+[i]); var containerDivId = containerDiv[i].getAttribute("id"); // Navigation var ul = containerDiv[i].getElementsByTagName("ul"); for(var j=0; j<ul.length; j++){ if (ul[j].className == kmrSimpleTabs.sbNavClass) { var a = ul[j].getElementsByTagName("a"); for(var k=0; k<a.length; k++){ a[k].setAttribute("id",containerDivId+"_a_"+k); // get current if(kmrSimpleTabs.readCookie('simpleTabsCookie')){ var cookieElements = kmrSimpleTabs.readCookie('simpleTabsCookie').split("_"); var curTabCont = cookieElements[1]; var curAnchor = cookieElements[2]; if(a[k].parentNode.parentNode.parentNode.getAttribute("id")==kmrSimpleTabs.sbIdPrefix+curTabCont){ if(a[k].getAttribute("id")==kmrSimpleTabs.sbIdPrefix+curTabCont+"_a_"+curAnchor){ a[k].className = kmrSimpleTabs.sbCurrentNavClass; } else { a[k].className = ""; } } else { a[0].className = kmrSimpleTabs.sbCurrentNavClass; } } else { a[0].className = kmrSimpleTabs.sbCurrentNavClass; } a[k].onclick = function(){ kmrSimpleTabs.setCurrent(this,'simpleTabsCookie'); return false; } } } } // Tab Content var div = containerDiv[i].getElementsByTagName("div"); var countDivs = 0; for(var l=0; l<div.length; l++){ if (div[l].className == kmrSimpleTabs.sbContentClass) { div[l].setAttribute("id",containerDivId+"_div_"+[countDivs]); if(kmrSimpleTabs.readCookie('simpleTabsCookie')){ var cookieElements = kmrSimpleTabs.readCookie('simpleTabsCookie').split("_"); var curTabCont = cookieElements[1]; var curAnchor = cookieElements[2]; if(div[l].parentNode.getAttribute("id")==kmrSimpleTabs.sbIdPrefix+curTabCont){ if(div[l].getAttribute("id")==kmrSimpleTabs.sbIdPrefix+curTabCont+"_div_"+curAnchor){ div[l].className = kmrSimpleTabs.sbContentClass+" "+kmrSimpleTabs.sbCurrentTabClass; } else { div[l].className = kmrSimpleTabs.sbContentClass; } } else { div[0].className = kmrSimpleTabs.sbContentClass+" "+kmrSimpleTabs.sbCurrentTabClass; } } else { div[0].className = kmrSimpleTabs.sbContentClass+" "+kmrSimpleTabs.sbCurrentTabClass; } countDivs++; } } // End navigation and content block handling } } }, // Function to set the current tab setCurrent: function(elm,cookie){ this.eraseCookie(cookie); //get container ID var thisContainerID = elm.parentNode.parentNode.parentNode.getAttribute("id"); // get current anchor position var regExpAnchor = thisContainerID+"_a_"; var thisLinkPosition = elm.getAttribute("id").replace(regExpAnchor,""); // change to clicked anchor var otherLinks = elm.parentNode.parentNode.getElementsByTagName("a"); for(var n=0; n<otherLinks.length; n++){ otherLinks[n].className = ""; } elm.className = kmrSimpleTabs.sbCurrentNavClass; // change to associated div var otherDivs = document.getElementById(thisContainerID).getElementsByTagName("div"); var RegExpForContentClass = new RegExp(kmrSimpleTabs.sbContentClass); for(var i=0; i<otherDivs.length; i++){ if ( RegExpForContentClass.test(otherDivs[i].className) ) { otherDivs[i].className = kmrSimpleTabs.sbContentClass; } } document.getElementById(thisContainerID+"_div_"+thisLinkPosition).className = kmrSimpleTabs.sbContentClass+" "+kmrSimpleTabs.sbCurrentTabClass; // get Tabs container ID var RegExpForPrefix = new RegExp(kmrSimpleTabs.sbIdPrefix); var thisContainerPosition = thisContainerID.replace(RegExpForPrefix,""); // set cookie this.createCookie(cookie,'simpleTabsCookie_'+thisContainerPosition+'_'+thisLinkPosition,1); }, // Cookies createCookie: function(name,value,days) { if (days) { var date = new Date(); date.setTime(date.getTime()+(days*24*60*60*1000)); var expires = "; expires="+date.toGMTString(); } else var expires = ""; document.cookie = name+"="+value+expires+"; path=/"; }, readCookie: function(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for(var i=0;i < ca.length;i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1,c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); } return null; }, eraseCookie: function(name) { this.createCookie(name,"",-1); }, // Loader addLoadEvent: function(func) { var oldonload = window.onload; if (typeof window.onload != 'function') { window.onload = func; } else { window.onload = function() { if (oldonload) { oldonload(); } func(); } } } // END }; // Load SimpleTabs kmrSimpleTabs.addLoadEvent(kmrSimpleTabs.init); 2) Code: function hideMessage() { document.getElementById("thanks").style.display="none"; } function startTimer() { var tim = window.setTimeout("hideMessage()", 5000); // 5000 milliseconds = 5 seconds } 3) Code: var ids=new Array(); function QAinit(){ if(document.getElementById){ var tids=document.getElementsByTagName('div'); for(i=0;i<tids.length;i++)if(tids[i].className=="question")ids[ids.length]=tids[i]; for(i=0;i<ids.length;i++)ids[i].onmouseup=setstate; }} function setstate(){ for(i=0;i<ids.length;i++){ if(ids[i]==this){ var d=this.parentNode.getElementsByTagName('div')[1]; if(d.style.display=="block")d.style.display="none"; else d.style.display="block"; }}} function expandall(){ if(document.getElementById){ for(i=0;i<ids.length;i++)ids[i].parentNode.getElementsByTagName('div')[1].style.display="block"; }} function collapseall(){ if(document.getElementById){ for(i=0;i<ids.length;i++)ids[i].parentNode.getElementsByTagName('div')[1].style.display="none"; }} window.onload=QAinit; Can anyone please help? When I call my controller function template it should select the template name from database and find the matching image.png Currently when I call the function from view via json it only displays no_image.png even though both links work. I have echoed and tested. For my controller it is CodeIgniter Based. How can I get my json script code work. It is calling URL fine. If image name does not match the $this->input->get('template') name should display no image. Codeigniter Controller Function Code: public function template() { $this->load->library('response'); if ($this->input->server('HTTPS')) { $server = HTTPS_SERVER; } else { $server = HTTP_SERVER; } if (is_file(FCPATH . '/image/' . 'templates/' . basename($this->input->get('template')) . '.png')) { $this->response->setOutput($server . 'image/templates/' . basename($this->input->get('template')) . '.png'); } else { $this->response->setOutput($server . 'image/no_image.jpg'); } } View Code: <div class="form-group"> <label class="col-sm-2 control-label" for="input-template"><?php echo $entry_template; ?></label> <div class="col-sm-10"> <select name="config_template" id="input-template" class="form-control"> <?php foreach ($templates as $template) { ?> <?php if ($template == $config_template) { ?> <option value="<?php echo $template; ?>" selected="selected"><?php echo $template; ?></option> <?php } else { ?> <option value="<?php echo $template; ?>"><?php echo $template; ?></option> <?php } ?> <?php } ?> </select> <br /> <img src="" alt="" id="template" class="img-thumbnail" /> </div> </div> </div><!-- / End Tab Website --> <div class="tab-pane" id="tab-local"> </div> <div class="tab-pane" id="tab-option">Option</div> <div class="tab-pane" id="tab-server">Server</div> </div> </form> </div> </div> </div> </div> <script type="text/javascript"><!-- $('select[name=\'config_template\']').on('change', function() { $.ajax({ url: 'http://localhost/codeigniter/admin/?c=website/&m=template&template=' + encodeURIComponent(this.value), dataType: 'html', beforeSend: function() { $('select[name=\'country_id\']').after(' <i class="fa fa-circle-o-notch fa-spin"></i>'); }, complete: function() { $('.fa-spin').remove(); }, success: function(html) { $('.fa-spin').remove(); $('#template').attr('src', html); }, error: function(xhr, ajaxOptions, thrownError) { alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); } }); }); $('select[name=\'config_template\']').trigger('change'); //--></script> Hello can please help convert this real simple slide show so that is plays immediately on page load. Thank you PHP Code: var ImgNum = 0; var ImgLength = NewImg.length - 1; //Time delay between Slides in milliseconds var delay = 7000; var lock = false; var run; function chgImg(direction) { if (document.images) { ImgNum = ImgNum + direction; if (ImgNum > ImgLength) { ImgNum = 0; } if (ImgNum < 0) { ImgNum = ImgLength; } document.slideshow.src = NewImg[ImgNum]; } } function auto() { if (lock == true) { lock = false; window.clearInterval(run); } else if (lock == false) { lock = true; run = setInterval("chgImg(1)", delay); } } Hi, I am facing a problem in passing replace() function as an argument in user defined java function, can any one help me how to resolve it? intention is to pass a file path to my user defined function, but before passing the path i want to replace the character '\' to '\\' I am posting my javascript function he <a href="#" onclick="OpenDocPreview('<%# Eval("PATH")%>'.replace(/\\/g,"\\\\"), '<%# Eval("Filename")%>')"><%# Eval("DocTitle") %></a> function OpenDocPreview(url, docname) { alert('message from search base : ' + url + ' ' + docname); } thank you, How can I call a PHP Function inside a Javascript Function? This is what I have so far, but I don't think I'm doing it the right way. Any suggestions? PHP Code: <?php function phpQuery(){ $query = mysql_query("INSERT INTO mytable VALUES('','name','email')"); } ?> <script type="text/javascript"> function delayQueries() { timeoutID = window.setTimeout(doQueries, 2000); } function doQueries() { var runQuery = "<?php phpQuery(); ?>"; } </script> I made a mouseover event of a caption on a picture, when I hover the opacity of the background color of the hover and the text goes down. What I want is that when I hover over the image which the caption is floating on, the onmouseover event gets activite. For an imaginary example: Code: function unhighlight(x) { x.style.backgroundColor="transparent" } Function ActivationFuction() { activate.function="unhighlight" } thanks Hi everyone, I am pretty new at javascript OOP. I have a javascript file that has plenty of javascript functions, variables, arrays, etc. I need to convert this into an object. Here is an example: Code: var myvar1 = ''; var myvar2 = new array(); var myvar3 = new array(); var myvar4; var myvar5 = 60; var myvar6 = ''; function myfunc1(){ myvar1 = 'hello'; return myvar1; } function myfunc2(somenum=0){ myvar5 = somenum; //calling myfunc1() from within this function. //do something in here } function myfunc3(){ //calling myfunc1() from within this function. for(i=0;i<somelength;i++){ myvar2 = myvar3[i]; (something to put into the array) } } 1. I need to create an object and put ALL the varibles (myvar1 - myvar5) in that object. 2. Then the first two functions "myfunc1 and myfunc2" inside the same object. 2. And the function myfunc3 needs to sit OUTSIDE my object as a regular javascript function. It calls on myfunc1 (which is inside the object) and also inserts data into myvar2 (which is classified inside the object) and myvar3 (which is classified inside the object as well). This is what i came up with, but it's not going well: Code: var myobj1 = function(){ this.myvar1 = ''; this.myvar2 = new array(); this.myvar3 = new array(); this.myvar4; this.myvar5 = 60; this.myvar6 = ''; var myfunc1 = function(){ this.myvar1 = 'hello'; return this.myvar1; } var myfunc2 = function(somenum=0;){ this.myvar5 = somenum; //calling this.myfunc1() from within this function. //do something in here } } function myfunc3(){ //calling mynewobj.myfunc1() from within this function. for(i=0;i<somelength;i++){ mynewobj.myvar2 = mynewobj.myvar3[i]; (something to put into the array) } } var mynewobj = myobj1; HELP.....!!!! i really want to get into object oriented world, so thanks in advance. If I use function or Function to create a javascript function, does it make any difference ? Whats the difference between two and in which situation shall I use either ? Likewise whats the difference between event and Event objects of JavaScript ? Thanks Hello, I have a php function PHP Code: function npclocs() { $npcl=$db->query("SELECT * FROM npclocation WHERE npclong < {$ir['userlongitute']}+5 AND npclong > {$ir['userlongitute']}-5 AND npclat > {$ir['userlatitude']}-5 AND npclat < {$ir['userlatitude']}+5 "); /*$npcarray = mysql_fetch_array($npcl);*/ $rows =0; while($row = $db->fetch_row($npcl)) { $nloc[]=$row; } foreach($nloc as $n) { echo "newpoints[" . $rows . "] = new Array(".$n['npclong'].", ".$n['npclat'].", ".$n['npciicon'].", ".$n['npclname'].", ".$n['npclname']."); "; $rows++; } } and I have a javascript function that I would like the results of this function to insert its results in the javascript here is the function in javascript Code: function addPoints() { //newpoints[0] = new Array(-73, 46, icon0, 'monroe', 'monroepopup'); //newpoints[1] = new Array(-69, 52, icon0, 'jackson', 'jacksonpopup'); //newpoints[2] = new Array(-45, 39, icon0, 'Benton', 'bentonpopup'); for(var i = 0; i < newpoints.length; i++) { var point = new GPoint(newpoints[i][1],newpoints[i][0]); var popuphtml = newpoints[i][4] ; var marker = createMarker(point,newpoints[i][2],popuphtml); map.addOverlay(marker); } } The commented out //newpoints is the old js array. my php function queries mysql and uses whiles and foreach to create the same output, as the old js array. I would like that php function result to insert its result into the js function. Is this possible? Thank you in advance. Hi I have a JavaScript function that has leaves floating around the screen and I need a way to have a checkbox turn on and off the function. Or I need a way to have a button turn off the script. I have the code to start the function on-loading the site. Any ideas are greatly appreciated. I got the falling leaves script from http://javascript.about.com/gi/o.htm...tip62.htm%3Ffm Please I have been having sleepless nights for days and could not resolve why this codes will not work. I will appreciate any assistance to resolve the coding reerroll the main problem is the function calculate (), does work when called. Please help <HTML> <HEAD> <TITLE>Feedback</TITLE> <SCRIPT TYPE="TEXT/JAVASCRIPT"> rate = new Array(4) rate[0] = 8 rate[1] = 4 rate[2] = 6 rate[3] = 12 function calculate() { howmuch = eval("document.form1.InsVal.Value") for(loop = 0; loop < document.form1.cover.length;loop++) if (document.form1.cover[loop].checked) level = loop + 1 where =document.form1.region.selectedIndex cost = eval(10 + howmuch /100*rate[where]*level) document.form1.guote.value =cost } function confirmPurchase() { if (confirm("Area you sure you wish to purchase insurance from us?")) document.form1.submit() } </SCRIPT> </HEAD> <BODY> <H1 ALIGN = CENTER>HotWheels</H1> <H2 ALIGN = CENTER>Skateboard Insurance Specialists</H2> <FORM NAME = form1 METHOD = post ACTION = "mailto:ioduwa@yahoo.com"> <P><B> Value of board:</B> <INPUT TYPE = text NAME = InsVal SIZE = 10> <P> Region <SELECT NAME= region> <OPTION = london> London <OPTION = southwest> South West <OPTION = rest>Rest of England <OPTION = wales>Wales </SELECT> <BR><INPUT TYPE = Radio NAME = cover> Third Party <BR><INPUT TYPE = Radio NAME = cover> Third Party Fire and Theft <BR><INPUT TYPE = Radio NAME = cover CHECKED> Comprehensive <P><INPUT TYPE = "button" NAME = "calc" VALUE = "Get guote" onClick ="calculate()"> <P><B> Your Quotation:<B> <INPUT TYPE = "text" NAME = "quote" SIZE = 10> <P><INPUT TYPE = "button" NAME = "done" VALUE = "Purchase" onClick = "comfirmPurchase()"> </FORM> </BODY> </HTML> |