JavaScript - Why Isn't This Code Running?
Code:
<html> <head> <script type="text/javascript"> function ChangeSize(objId,ToWidth,ToHeight,Spd) { CurrentWidth=parseInt(document.getElementById(objId).style.width); // CurrentHeight=parseInt(document.getElementById(objId).style.height); if(CurrentWidth<>ToWidth) { WidthDiff=ToWidth-CurrentWidth; if (Spd<WidthDiff) {Spd=round(WidthDiff/2);} CurrentWidth=CurrentWidth+Spd; document.getElementById(objId).style.width=CurrentWidth+'px'; TimeoutCmd="ChangeSize(\""+objId+"\","+ToWidth+","+ToHeight+","+Spd+");"; setTimeout(TimeoutCmd,1); } document.getElementById(objId).innerHTML=document.getElementById(objId).style.width; } </script> </head> <body> <div id="ChangeSizeDiv" style="width:200px;height:200px;border:5px groove green;overflow:hidden" onclick='ChangeSize("ChangeSizeDiv",500,500,15);'> Click here to resize me ... </div> </body> </html> I don't see any typos (though that doesn't mean I'm not blind). It doesn't even appear to be firing when I click the div. What's up? Similar TutorialsThe first time I enter the command n it should run the first if statement, when I enter n it should then run the second one as its in zone two. However this is just not happening... What am I doing wrong. Its simply running the second one and skipping the first. Thanks in advance folks // gameFunctions.js // Javascript file for Game.html // September 29th 2010 Edition // The below represent our global variables for the game. The first variable // is called playerScore, and represents the total earned points. The player // earns or loses points based on progress in the game, this value can either // increase or decrease. var playerLocation = "zone"; function runProgram() { var command = ""; command = document.getElementById("txtCommand").value; switch (command) { case "n": north(); break; case "s": south(); break; case "e": east(); break; case "w": west(); break; case "north": north(); break; case "south": south(); break; case "east": east(); break; case "west": west(); break; default: giveError(); } } // The following function when called will take the player north. function north() { if(playerLocation = "zone") { var message = "You have come to what seems to be a beach"; post(message); var playerLocation = "zoneTwo"; } if(playerLocation = "zoneTwo") { var message = "You are unsure if you should set up camp. Set up camp?" post(message); var playerLocation = "zoneThree"; } else { giveError(); } } // The following function when called will take the player east. function east() { if(playerLocation = "zone") { var message = "You have come to a very large and steep mountain"; post(message); var playerLocation = "zoneTwo"; } if(playerLocation = "zoneTwo") { var message = "You are unsure if you should set up camp. Set up Camp?"; post(message); var playerLocation = "zoneThree"; } else { giveError(); } } // The following function when called will take the player south. function south() { if(playerLocation = "zone") { var message = "You have come to the entrance of a mine"; post(message); var playerLocation = "zoneTwo"; } if(playerLocation = "zoneTwo") { var message = "You are unsure if you should set up camp. Set up Camp?"; post(message); var playerLocation = "zoneThree"; } else { giveError(); } } } // The following function when called will take the player west. function west() { if(playerLocation = "zone") { var message = "You have found the edge of the world"; post(message); var playerLocation = "zoneTwo"; } if(playerLocation = "zoneTwo") { var message = "You are unsure if you should set up camp. Set up Camp?"; post(message); var playerLocation = "zoneThree"; } else { giveError(); } } // The following function reports an error when the program deviates from standard functionality. It is used mainly for debugging. function giveError() { alert("gameFunctions.js has encountered a critical error") alert("Please check that you are not using Internet Explorer to run this page") alert("The program will now close") } // The following function reports an error when the typed in command is not recognized by the program database. function doNotUnderstand() { alert("I am sorry but I do not understand please try again") } function post(newText) { document.getElementById("taGameText").value = "" var gameTextBox = document.getElementById("taGameText"); gameTextBox.value = newText + gameTextBox.value; } Hey all. I hate posting this problem, because I am quite embarrassed by this script I have put together. This is not the final script, it is a draft, but I am trying to learn as much as possible and I would like to fix this before I move on and completely rewrite it. As you can probably tell - this is my first crack at JS... Right now I have a page with a registration form, seen he http://www.temp1.hangnailproductions...gistration.php It is working as well as it can be in FireFox, but in IE it is not working at all. Now, I just ran the IE8 debugger, and my first problem is the onload function in the body tag, it is saying that an object is missing, but I do not understand what this means. Can anyone help me with this please? Again, sorry for asking for help on such a mess, but like I said - I need to learn and trial and error works best for me... Thanks very much. I have changed my event listener around a bit. Basically the "compare_fields" function is running when the "load_doc" function is run. Here is my JavaScript: PHP Code: function load_doc(doc, parent) { document.getElementById(parent).innerHTML = "<h1>Loading...</h1>"; var http = getHTTPObject(); if (http != undefined) { http.onreadystatechange = function() { req_doc(doc, parent, http); }; http.open("GET", doc, true); http.send(""); } } function req_doc(doc, parent, req) { if (req.readyState == 4) {//only if req is loaded if (req.status == 200) {//And if its okay document.getElementById(parent).innerHTML = req.responseText; add_event_listeners(page) } else { document.getElementById(parent).innerHTML = "Error fetching data: " + req.status + "\n" + req.statusText; add_event_listeners(); } } } //Script used to hide elements. Usage: expand(element id) function expand(elm) { var ex = document.getElementById(elm).style.display; if (ex == "none") { var obj = document.getElementById(elm); obj.style.display = "inline"; } else if (ex == "inline") { var obj = document.getElementById(elm); obj.style.display = "none"; } } function check_database(obj) { //Not written yet } //Function to test the password validation, should rewrite in future //to make it multifunctional function compare_fields(obj) { alert("com"); var field2 = obj.split("_"); field2 = document.getElementById(field2[1]+"2"); if (obj == field2) { if (obj.length >= 4) { document.getElementById("pass_status").style.color = "#00CC00"; document.getElementById("pass_status").innerHTML = "OK!"; } else { document.getElementById("pass_status").innerHTML = "Please must be between 5 - 14 characters long! "; document.getElementById("pass_status").style.color = "#FF0000"; } } else { document.getElementById("pass_status").innerHTML = "Passwords do not match!"; document.getElementById("pass_status").style.color = "#FF0000"; } } Global JavaScript: PHP Code: //Get httpobject function getHTTPObject() { var http = false; if (window.XMLHttpRequest) { http = new XMLHttpRequest(); } else if (window.ActiveXObject) { http = new ActiveXObject("Microsoft.XMLHTTP"); } return http; } //This function attaches events to elements. var addEvent = function( elm, evt, fun ) { if ( elm.addEventListener ) { elm.addEventListener( evt, fun, false ); } else if ( elm.attachEvent ) { elm.attachEvent( 'on' + evt, fun ); } else { elm [ 'on' + evt ] = fun; } }; Here is the first form, this contains the button: Code: <div style="border-color:#09C; border-width:1px; border-style:solid;"> <div class="register_button" onClick="load_doc('pages/forms/register_form.php', 'login_form')">Register</div> <h1>Login</h1> <h3>DrawSomething - WordGuesser</h3> <br /> <form id="login" action="php/check_login.php" method="post"> Username<br /><input type="text" name="username" class="text login_field"><br /> Password<br /><input type="password" name="password" class="text login_field"><br /> <input type="submit" value="Login" class="button blue" /> </form> <br /> <h2>Forgot Username/Password?</h2> <span class="expand" onClick="expand('forgot_p')"></span> <form class="forgot_p" action="php/forgot_p.php" method="post" style="display:none;" id="forgot_p"> Email<br /> <h3>Recover username</h3> <input type="text" name="forgot_email" class="text login_field"><br /> <span style=" font-weight:bold; font-size:21px;">- OR -</span><br /> Username<br /> <h3>Recover password</h3> <input type="text" name="forgot_password" class="text login_field"><br /> <input type="submit" value="Recover" class="button" /> </form> </div> Form which is loaded, this is when the "comare_fields" function is run when it shouldn't be. Edit: Oh and here is the PHP script which creates the event listeners. PHP Code: include "js/common.js"; include $js[$page]; //Write JS variables for event listeners $page_listeners = $listeners[$page]; //Check if there are some event listeners for this page if (count($page_listeners) > 0) { ///Start function echo "function add_event_listeners() { "; //Start loop to add event listeners for ($i = 0; $i < count($page_listeners); $i++) { $doc_elm = "document.getElementById('".$page_listeners[$i][1]."')"; echo "addEvent(\"document.getElementById('".$page_listeners[$i][0]."')\", \"".$page_listeners[$i][1]."\", ".$page_listeners[$i][2].");"."\n"; } //End function echo "}"; } Code that is written with the above PHP Code: function add_event_listeners() { addEvent("document.getElementById('reg_username')", "click", check_database); addEvent("document.getElementById('reg_email')", "click", check_database); addEvent("document.getElementById('reg_password')", "click", compare_fields('reg_password')); } And here are global PHP variables: PHP Code: <?php //Define page titles $titles = array( "login" => "Login - DrawSomething", "main" => "DrawSomething - Word Guesser", "admin" => "Administrator" ); //Require JavaScript files when onscreen HTML is selected $js = array( "login" => "js/login_js.js", "main" => "js/main_js.js", "admin" => "js/admin_js.js" ); //Pages to require $pages = array( "login" => "pages/login_page.php", "main" => "pages/main_page.php", "admin" => "pages/admin_page.php" ); //Event listeners to add $listeners = array( "login" => array(array("reg_username", "click", "check_database"), array("reg_email", "click", "check_database"), array("reg_password", "click", "compare_fields('reg_password')") ), ); ?> Hi Guys, I'm remotely new to the world of scripting in general. I'm trying to run two scripts: Coda Slider (http://www.ndoherty.biz/tag/coda-slider/) and OS X Style Dialogue (http://www.ericmmartin.com/projects/simplemodal-demos/) But I'm am having difficulty doing so. I've heard the term "script confliction" throw around a lot - but I don't know how to solve it. My scripting code can be seen on the practice website: http://thenativedrum.com/practice/ Any help would be greatly appreciated. Thanks in advance! I currently have a script setup in HTML that will allow me too input a "Customers ID" and their "Gas Usage". Once those are entered, it will do some calculations and display text stating: > "Customers ID: 1 has gas usage of 50 and owes $100 > > Customers ID: 2 has gas usage of 120 and owes $195 > > Customers ID: 3 has gas usage of 85 and owes $142.5 > > Customers ID: 4 has gas usage of 65 and owes $112.5 > > Total amount of customers is: > > Total amount owed all customers:" **What im having trouble** with is making a running total that will calculate the "Total amount of customers" and the "Total amount owed by customers". All I know is that I may need to add another variable in the script. Code: function Summarise() { ID = prompt("Enter a Customer ID number ", -1) while(ID != -1) { var gasUsed = 0 gasUsed = prompt("Enter amount of gas used ", "0") var total = 0 ///Standard Rate is used to assist in the calculation of customers in excess of 60 Gas Used StandardRate = 60 * 1.75 if(gasUsed <= 60) { total= gasUsed * 2 document.write("Customers ID: " + ID) document.write(" has gas usage of " + gasUsed) document.write(" and owes $" + total) document.write("<br/>") } else { total= (gasUsed - 60) * 1.50 + StandardRate document.write("Customers ID: " + ID) document.write(" has gas usage of " + gasUsed) document.write(" and owes $" + total) document.write("<br/>") } ID = prompt("Enter a Customer ID number ", -1) } } I want to run a flash video on my web site. I've been working on this for days now, and obviously missing something. The page is really BRIEF -- nothing more than <object> calls and swfobject.registerObject call. when I look at it on the server, I get a totally blank page in IE. In firefox, I see a little "block" tab where the movie frame would be if it worked. Here is the whole code: thanks so much for looking at it. Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <LINK REL="SHORTCUT ICON" HREF="http://olympiceq.com/favicon.ico"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Olympic Equine</title> </head> <body> <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="360" height="264" id="FLVPlayer"> <param name="movie" value="FLVPlayer_Progressive.swf" /> <param name="quality" value="high" /> <param name="wmode" value="opaque" /> <param name="scale" value="noscale" /> <param name="salign" value="lt" /> <param name="FlashVars" value="&MM_ComponentVersion=1&skinName=Corona_Skin_2&streamName=HorseswithClicktoPlay&autoPlay=false&autoRewind=false" /> <param name="swfversion" value="8,0,0,0" /> <!-- This param tag prompts users with Flash Player 6.0 r65 and higher to download the latest version of Flash Player. Delete it if you don’t want users to see the prompt. --> <param name="expressinstall" value="expressInstall.swf" /> <!-- Next object tag is for non-IE browsers. So hide it from IE using IECC. --> <!--[if !IE]>--> <object type="application/x-shockwave-flash" data="FLVPlayer_Progressive.swf" width="360" height="264"> <!--<![endif]--> <param name="quality" value="high" /> <param name="wmode" value="opaque" /> <param name="scale" value="noscale" /> <param name="salign" value="lt" /> <param name="FlashVars" value="&MM_ComponentVersion=1&skinName=Corona_Skin_2&streamName=HorseswithClicktoPlay&autoPlay=false&autoRewind=false" /> <param name="swfversion" value="8,0,0,0" /> <param name="expressinstall" value="expressInstall.swf" /> <!-- The browser displays the following alternative content for users with Flash Player 6.0 and older. --> <div> <h4>Content on this page requires a newer version of Adobe Flash Player.</h4> <p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p> </div> <!--[if !IE]>--> </object> <!--<![endif]--> </object> <script type="text/javascript"> <!-- swfobject.registerObject("FLVPlayer"); //--> </script> </body> </html> i noticed the majority of the time when i practice coding javascript and run it, it never runs in the order i want it to. WHY?! like for example, if i want something to happen ONLY WHEN A BUTTON IS CLICKED, it would instead happen on page load :S its soooo frustrating heres one of my practice code which illustrates this problem. This code is suppose the stretch a div only wen it is clicked on. 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> </head> <body> <div id="mybutton" style="height:50px; width:50px; background-color:#C00;"></div> </body> <script type="text/javascript"> var left = 0; var funct = function () { //alert("Thank you for clicking me"); left +=10; b.style.height = left + 'px'; if(left < 100) { var id = setTimeout(funct, 10); } } var b = document.getElementById("mybutton"); b.onclick = funct(); </script> </html> I have an external js file which contains the function which for now opens an alert box. The div on the page should run the function when it is clicked but it isn't. I have tried changing the function to an alert to check the click event is working and i have tried running the javascript in the address bar Code: javascript:hasFocus(); to ensure it has loaded correctly. Both are working fine and i am getting no errors. Below is a snippet of the code: Code: function hasFocus() { alert("a"); } 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> <script type="text/javascript" language="javascript" src="scripts/cms.js"></script> </head> <body> <div id="tab_panel"> <div id="tabs"></div> <div id="content" contenteditable="true" onclick="hasFocus();"></div> </div> </body> </html> Thanks in advance Hello Firstly, this is the full pastebin code of my admin page because i failed adding full code here correctly: http://pastebin.com/tQAaQjYC and the screenshot of the slide manager page: http://img36.imageshack.us/img36/4830/slidemanager.jpg Well, I have a Slide Manager as an admin menu page in Wordpress. When i click "Add new slide" button, as you see in the screenshot above, it adds a new "slide field" in which that dropdown list shows all titles of posts. (Ignore other parts as they work as expected) What i would like to do is, when i choose a post title, the text box which is next to dropdown to be populated automatically by the post's url adress. I want it to be worked for every "slide field" added via "Add new slide" button. I actually made it work that way outside the foreach: PHP Code: <script language="JavaScript"><!-- function onChange() { var Current = document.myform.link.selectedIndex; document.myform.currentText3.value = document.myform.link.options[Current].value; } //--> </script> <select name="link" onChange="onChange(this.value);"> <?php if($_POST['action'] == save ) { $selected = "selected"; } else{ $selected = ""; } echo '<option value="">...... Choose One ...... </option>'; $args = array( 'post_type' => 'post', 'nopaging' => true ); $the_query = new WP_Query( $args ); while ( $the_query->have_posts() ) : $the_query->the_post(); echo '<option '.$selected.' value="'.get_permalink( $post->ID ).'">'; the_title(); echo '</option>'; endwhile; ?> </select> <input name="currentText3" type="text" value=""> But when i add this after the opening code of foreach, i.e: PHP Code: <?php foreach($nivoslides as $k => $slide) : ?> Each slide field shows the dropdown and text box properly as you see in screenshot BUT none of them work. I tried to add brackets but it didn't work either: Code: <select name="link[]" onChange="onChange(this.value);"> I guess it's the javascript code that should be edited or entirely changed but i have no idea how to do it. I would be grateful for any help. Thanks in advance. I have this file: IPToned.js Code: // ==UserScript== // @name IPToned // @namespace http://users9.jabry.com/chatleague // @description IPTorrents Filter Enhancements // ==/UserScript== alert("hello world"); I drag and drop it into Firefox (Ubuntu) and it opens it as if it were a txt file. I want it to make the alert so I can get to coding. Any suggestions? Hi, I have just started to learn Javascript which when loaded into a safari web browser of Firefox browser just simply displays the code. I am currently using a MacBook Leopard operating system I have saved the code (corrected for mistakes, many many times) to my desktop Run my usual browser safari (and tried same with Firefox) loaded the file and all I get is a copy of the code displayed in the browser window. Javascript is enabled for both Please can you suggest some options for me to try and get the code working. All I am doing in this example is copied from a book to turn the background colour of the browser RED Thanks Tom Hey guys, I have a script that I'm running for a select box, and I need to run it twice now for another select box. Unfortunately if I duplicate it, it will not run at all. Im sure there is a way to combine these two so they both run. Any help very much appreciated! I have colored the text that differs between the two instances in red. Runs fine individually but not the two together . Code: <!--[][][][][][][][] Job Contacts Script --> <script type="text/javascript"> function show Customer (str) {var xmlhttp; if (str=="") {document.getElementById(" txtHint ").innerHTML=""; return;} 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(" txtHint ").innerHTML=xmlhttp.responseText;}} xmlhttp.open("GET"," getcustomer.asp ?q="+str,true); xmlhttp.send(); }window.onload = function() { document.getElementsByName(' customers ')[0].onchange();}; </script> <!--[][][][][][][][] Job Ship Site Script --> <script type="text/javascript"> function show Shipto (str) {var xmlhttp; if (str=="") {document.getElementById(" txtHint2 ").innerHTML=""; return;} 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(" txtHint2 ").innerHTML=xmlhttp.responseText;}} xmlhttp.open("GET"," getshipsite.asp ?q="+str,true); xmlhttp.send(); }window.onload = function() { document.getElementsByName( 'shipsites ')[0].onchange();}; </script> I recently coded a page that extracts certain nodes from an external XML file and prints a line of text on the webpage. It is an HTML page that is strictly devoted to this purpose. There is no other information on it. The page is currently stored locally on my computer, and when I open it, the script runs fine and outputs the correct text. However, when I transferred this script over to my web server, and locate it that way, it doesn't run correctly. When I go to the page, it is supposed to display a line of text at the top. It does when I run the file from my local machine, however when I open it from the server, it doesn't display this text. (Same browser, same computer) When I right-click and view the source, all the code is there, and the files are identical. Any idea as to why the script runs correctly only when I open the HTML page locally? I appreciate any help or advice. Thanks! Hey, so i've been learning basics and I can get the following code to work as a prompt and I thought hey, I wounder if I can get it to work of a UI system, so I edited the code and got this Read Below Post Can you please help me to find where I am going wrong. Thanks MancunianMacca Okay I am sure my script is loading when the page loads because of the alert box I have added but when I click on the button that is suppose to activate the script nothing happens. The button code is as follows: <button type="button" name="submit" value="submit" class="css3button" onclick="send(nick,passwd,userid,chan,showtime,showjoin,showpart,showquit,fname,fsize,nnick1,nnick2, nnick3,nnick4,nnick5)">Connect</button> I may be using the button wrong but I am new to javascript. Any suggestions would help. I am trying to run javascript within Iframe and its not running. (The bigger pictu The final target is to do a file upload without refreshing the page, and the original code is using the iframe as the target of the form, and the return from the server is a javascript code that should update some status field on the page. However the code return from the server is not running, so I just paste it in the iframe and it is still not running. ) Code: Content-type: text/html\n\n <html> <script type="text/javascript"> alert("this is running") </script> <iframe id="upload_target" name="upload_target" src="#" style="width:100;height:100;border:0px solid #fff;"> <script type="text/javascript"> alert("this not running") </script> </iframe> </html> I am having a bit of trouble adding the drop down options to the running total. I managed to get the check boxes and radio buttons to work fine, but can't figure out how to get the drop downs working. Basically when small is selected it adds $10 to the running total, medium $15 and large $20. 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>Pizza</title> <script type="text/javascript"> function CalculateTotal(inputItem) { var frm=inputItem.form; if (!frm.fields) frm.fields=''; if (!frm.fields.match(inputItem.name)) frm.fields+=inputItem.name+',' // add the inputItem name to frm.fields var fieldary=frm.fields.split(','); // convert frm.fields to an array var cal=0; for (var zxc0=0;zxc0<fieldary.length-1;zxc0++){ // loop through the field names var input=document.getElementsByName(fieldary[zxc0]); // an array of fields with the mame for (var zxc0a=0;zxc0a<input.length;zxc0a++){ // loop through the input array to detect checked fields if (input[zxc0a].checked) cal+=input[zxc0a].value*1; // convert the value to a number and add to cal } } frm.calculatedTotal.value=cal; frm.total.value=formatCurrency(cal); } // format a value as currency. function formatCurrency(num) { num = num.toString().replace(/\$|\,/g,''); if(isNaN(num)) num = "0"; sign = (num == (num = Math.abs(num))); num = Math.floor(num*100+0.50000000001); cents = num%100; num = Math.floor(num/100).toString(); if(cents<10) cents = "0" + cents; for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++) num = num.substring(0,num.length-(4*i+3)) + ',' + num.substring(num.length-(4*i+3)); return (((sign)?'':'-') + '$' + num + '.' + cents); } // This function initialzes all the form elements to default values function InitForm() { //Reset values on form var frm=document.selectionForm; frm.total.value='$0.00'; // set initial total frm.calculatedTotal.value=0; frm.previouslySelectedRadioButton.value=0; //Set all checkboxes and radio buttons on form to unchecked: for (i=0; i < frm.elements.length; i++) { if (frm.elements[i].type == 'checkbox' || frm.elements[i].type == 'radio') { frm.elements[i].checked =(frm.elements[i].value!='0.00')? false:true; } } } </script> </head> <body onLoad="InitForm();" onreset="InitForm();"> <table width="770" height="171" border="1" cellpadding="3"> <tr> <td colspan="2"><p>PIZZA ORDERS SCREEN Welcome: [username] Time: [current time] </p> <p>Select the requirements of the CLIENT's pizza below</p></td> </tr> <tr> <td width="462"><form method="POST" name="selectionForm"> <fieldset> <legend>NEW PIZZA SELECTION</legend> (pricing estimate) <p>Select the size pizza (base price of all types): <select name="SIZE" > <option name="small" value=10.0 selected>small ($10)</option> <option name="medium" value=15.00 onchange="CalculateTotal(this);">medium ($15)</option> <option name="large" value=20.00 >large ($20)</option> </select> </p> Select pizza type: <table width="292"> <tr> <td><label> <input type="radio" name="type" value="radio" id="RadioGroup1_0" /> Supreme <input type="radio" name="type" value="radio" id="RadioGroup1_1" /> Meat Lovers <input type="radio" name="type" value="radio" id="RadioGroup1_2" /> Aussie</label></td> </tr> </table> <p>Select additional topping (each topping is $2.50): </p> <table width="200" border="0" cellspacing="5" cellpadding="1"> <tr> <td width="70">Ham: </td> <td width="111"> <input type="checkbox" name="ham" value=2.50 onclick="CalculateTotal(this);"></td> </tr> <tr> <td width="70">Cheese: </td> <td width="111"> <input type="checkbox" name="cheese" value=2.50 onclick="CalculateTotal(this);"></td> </tr> <tr> <td width="70">Olives: </td> <td width="111"> <input type="checkbox" name="olives" value=2.50 onclick="CalculateTotal(this);"></td> </tr> <tr> <td width="70">Peppers: </td> <td width="111"> <input type="checkbox" name="peppers" value=2.50 onclick="CalculateTotal(this);"></td> </tr> <tr> <td width="70">Anchovies: </td> <td width="111"> <input type="checkbox" name="anchovies" value=2.50 onclick="CalculateTotal(this);"></td> </tr> <tr> <td width="70">Salami: </td> <td width="111"> <input type="checkbox" name="salami" value=2.50 onclick="CalculateTotal(this);"></td> </tr> </table> <p> </p> <p>Select the type of packaging: </p> <table width="200"> <tr> <td> <input type="radio" name="Sauce" value=1.00 onClick="CalculateTotal(this);"> Plastic $1.00 </td> </tr> <tr> <td> <input type="radio" name="Sauce" value=1.00 onClick="CalculateTotal(this);"> Plastic $1.00 </td> </tr> <tr> <td> <input type="radio" name="Sauce" value=1.00 onClick="CalculateTotal(this);"> Plastic $1.00 </td> </tr> </table> <p> <input type="hidden" name="calculatedTotal" value=0> <input type="hidden" name="previouslySelectedRadioButton" value=0> <font size=+1> Your total is: </font><font face=Arial size=2><font size=+1> <input type="text" name="total" readonly onFocus="this.blur();"> <br /> </p> <p> <input type="button" name="resetBtn" id="resetBtn" value="Reset" /> <input type="button" name="confirmBtn" id="confirmBtn" value="ADD TO ORDER" /> </p> </fieldset> </form></td> <td width="284" align="left" valign="top"> <form id="summaryForm" name="summaryForm" method="post" action=""> <fieldset><legend>CLIENT ORDER SUMMARY</legend> <p> <textarea name="summaryBox" cols="40" rows="20"></textarea> </p> <p>Number of Pizza's: <label for="noPizza"></label> <input name="noPizza" type="text" id="noPizza" size="5" /> </p> <p>Total for Pizza's: <input name="totPizza" type="text" id="totPizza" size="8" /> </p> <p>Email a confirmation: <input type="submit" name="email" id="email" value="KITCHEN CONFIRMATION" /> <br /> </p></fieldset> </form> <p> </p></td> </tr> <tr> <td colspan="2" align="right"><form id="form1" name="form1" method="post" action=""> <input type="button" name="reset all" id="reset all" value="RESET for New client" /> <input type="hidden" name="calculatedTotal" value=0> <input type="hidden" name="previouslySelectedRadioButton" value=0> </font> </p> </form></td> </tr> <tr> </table> </body> </html> Hello I am setting up a Javascript function in a page called functions.php function onAddBookmarkPressed() { <? mail("XXXXXXX", "Mail","Bookmark"); ?> } And calling it from another place within the page <div class="barstepimg"><img src="http://staggan.com/my_dir/images/progress_bar/fb_buttons/add_bookmark.gif" onclick="onAddBookmarkPressed();"/></div> I include functions.php in my index.php page... When I run the index.php page the function above runs and emails me... Any idea why? Is there a way that I can run a second set of this script on the same page at the same time? If I want a 2nd instance of this script to run on the same page...what values would I need to rename in the 2nd instance? When I try to place this script a second time it only shows the 2nd scripts values or banner ads... I'm trying to make a Banner rotation placement on my sites inner pages (It's a Wordpress powered site) One Set of Banners that ROTATE directly Above Another Set... I like this script since it allows for a Random order on each page load and will ALSO cycle through Each Banner once before repeating the order, That way Each Advertiser will get seen before another is seen a second or third time... I know there are plug-ins for wordpress for advertising, but I have not found any that will rotate out the banners every x niumber of seconds, like this does... Is there a way that I can run a second set of this script on the same page at the same time? <script type="text/javascript"> // Flexible Image Slideshow- By JavaScriptKit.com (http://www.javascriptkit.com) // For this and over 400+ free scripts, visit JavaScript Kit- http://www.javascriptkit.com/ // This notice must stay intact for use var ultimateshow=new Array() //ultimateshow[x]=["path to image", "OPTIONAL link for image", "OPTIONAL link target"] ultimateshow[0]=['http://www.rockinghamcountymerchants.com/CraigTravis/CraigTravis250x250.jpg', 'http://tcraigtravis.com/', '_new'] ultimateshow[1]=['http://www.rceno.com/RCENO/bannerads/elizabethspizza/elizabethspizza250x250.jpg', 'http://www.rceno.com/RCENO/advertisers/elizabethspizza/index.html', '_new'] ultimateshow[2]=['http://www.rceno.com/RCENO/bannerads/gavinsmightychamps/gavin250x250.jpg', 'http://www.gavinsmightychamps.com/index.html', '_new'] ultimateshow[3]=['http://www.rceno.com/RCENO/bannerads/redrivergrill/RedRiver2420-250x250.jpg', 'http://www.rockinghamcountymerchants.com/redrivergrill', '_new'] ultimateshow[4]=['http://www.rceno.com/RCENO/bannerads/qualitycleaners/QC250x250-011510.jpg', 'http://www.rockinghamcountymerchants.com/qualitycleaners', '_new'] //configure the below 3 variables to set the dimension/background color of the slideshow var slidewidth="250px" //set to width of LARGEST image in your slideshow var slideheight="250px" //set to height of LARGEST iamge in your slideshow var slidecycles="continous" //number of cycles before slideshow stops (ie: "2" or "continous") var randomorder="yes" //randomize the order in which images are displayed? "yes" or "no" var preloadimages="yes" //preload images? "yes" or "no" var slidebgcolor='white' //configure the below variable to determine the delay between image rotations (in miliseconds) var slidedelay=9000 ////Do not edit pass this line//////////////// var ie=document.all var dom=document.getElementById var curcycle=0 if (preloadimages=="yes"){ for (i=0;i<ultimateshow.length;i++){ var cacheimage=new Image() cacheimage.src=ultimateshow[i][0] } } var currentslide=0 function randomize(targetarray){ ultimateshowCopy=new Array() var the_one var z=0 while (z<targetarray.length){ the_one=Math.floor(Math.random()*targetarray.length) if (targetarray[the_one]!="_selected!"){ ultimateshowCopy[z]=targetarray[the_one] targetarray[the_one]="_selected!" z++ } } } if (randomorder=="yes") randomize(ultimateshow) else ultimateshowCopy=ultimateshow function rotateimages(){ curcycle=(currentslide==0)? curcycle+1 : curcycle ultcontainer='<center>' if (ultimateshowCopy[currentslide][1]!="") ultcontainer+='<a href="'+ultimateshowCopy[currentslide][1]+'" target="'+ultimateshowCopy[currentslide][2]+'">' ultcontainer+='<img src="'+ultimateshowCopy[currentslide][0]+'" border="0">' if (ultimateshowCopy[currentslide][1]!="") ultcontainer+='</a>' ultcontainer+='</center>' if (ie||dom) crossrotateobj.innerHTML=ultcontainer if (currentslide==ultimateshow.length-1) currentslide=0 else currentslide++ if (curcycle==parseInt(slidecycles) && currentslide==0) return setTimeout("rotateimages()",slidedelay) } if (ie||dom) document.write('<div id="slidedom" style="width:'+slidewidth+';height:'+slideheight+'; background-color:'+slidebgcolor+'"></div>') function start_slider(){ crossrotateobj=dom? document.getElementById("slidedom") : document.all.slidedom rotateimages() } if (ie||dom) window.onload=start_slider </script> In Other words I would have one set of 5 ads rotating and directly below it another set of 5 Ads |