JavaScript - Firefox Autofill Forms Plugin - Choose Random Values For Forms
I'm using the autofill forms plugin for firefox which can be found he
https://addons.mozilla.org/en-US/firefox/addon/4775 I use it to automatically fill various web forms, duh. But I would like certain values to be chosend randomly from a list I create. I contacted the developer and he said the add on probably does not need a new feature because there is a 'dynamic tags' function to fill certain forms with dynamic values (e.g. the current time or date). He has given over the project to another developer and told me I probably would find a solution in a good javascript programming forum. So here I am! Can anyone help me with this? Basically, I just need a javascript code which chooses on item from an array randomly, I guess? I'm not a programmer myself, so any help would be greatly (!) appreciated. Thanks a lot in advance for any further guidance! Note: Here are sample dynamic tags from the plugin: <datetime> new Date().toLocaleString() <useragent> navigator.userAgent <langcode> navigator.language <resolution> screen.width+'x'+screen.height <clipboard> this.getClipboardText() Similar TutorialsI am trying to split the (id) values between seperate forms and the submit buttons are not located between the form tags. Note: ->The 3 forms are located at the top of page ->the (3) Submit buttons are in a query and are outside the form tags. ->In this case it does not make sense to have the form duplicating itself in the sql_query. need the correct code for the 3 script functions var form1, form2, form3 then i need the correct function submit code something like -> onClick='Split(this.form1,1)' Also: To keep this simple could the 3 scripts be combined into one? Code: <!-- SPLIT VALUES BETWEEN SEPERATE FORMS --> <script type="text/javascript"> function Add(sel,first) { if (sel.selectedIndex == 0 ) return; var temp = sel.id.split(","); sel.form1["F"+first].value = temp[0]; sel.form1["F"+(first+1)].value = temp[1]; } </script> <script type="text/javascript"> function Edit(sel,first) { if (sel.selectedIndex == 0 ) return; var temp = sel.id.split(","); sel.form2["F"+first].value = temp[0]; sel.form2["F"+(first+1)].value = temp[1]; } </script> <script type="text/javascript"> function Delete(sel,first) { if (sel.selectedIndex == 0 ) return; var temp = sel.id.split(","); sel.form3"F"+first].value = temp[0]; sel.form3["F"+(first+1)].value = temp[1]; } </script> <form method='post' name='form1' action='record_add.php'> <input type='hidden' id='F1' name='t101' value='' > <input type='hidden' id='F2' name='t102' value='' > </form> <form method='post' name='form2' action='record_edit.php'> <input type='hidden' id='F3' name='t103' value='' > <input type='hidden' id='F4' name='t104' value='' > </form> <form method='post' name='form3' action='record_delete.php'> <input type='hidden' id='F5' name='t103' value='' > <input type='hidden' id='F6' name='t106' value='' > </form> <!-- NOTE: THE SUBMIT BUTTONS ARE IN A QUERY OUTSIDE THE FORM TAGS AND NEED TO TARGET THE PROPER FORM1,2,3 onClick --> <button type='submit' id='$mytable,$columns[Field]' onClick='Split(this.form1,1)'> <button type='submit' id='$mytable,$columns[Field]' onClick='Split(this.form2,3)'> <button type='submit' id='$mytable,$columns[Field]' onClick='Split(this.form3,5)'> Hey CF, I'm currently working on a website called 'eXtreme Gaming' I've almost completed it, apart from two things. - Adding two values on my checkout page for the Grandtotal (I've tried everything, but I'm too much of a noob and have probably missed something small). - Validation of forms (I don't know where to start here, I've looked on w3schools for tuts etc but I'm having difficulty incorporating it on my site) I'm going to put the code for my checkOut page only, if you are able to help me many thanks in advance. [quote] Code: <HTML> <HEAD> <script language="JavaScript" src="laptopsCookie.js"> </script> <script language="JavaScript" src="desktopsCookie.js"> </script> <script language="JavaScript"><!-- function calculateTotalPurchaseLaptop(formRef) { var laptopTotal=0; for (var i=0; i<LaptopListPurchase.length/2;i++) { var subTotal = formRef.elements['quantity'+i].value * formRef.elements['price'+i].value; formRef.elements['subTotal'+i].value = subTotal.toFixed(2); // document.orderForm2.grandTotal.value = document.orderForm.laptopTotal.value + document.orderForm2.desktopTotal.value laptopTotal += subTotal; } formRef.laptopTotal.value = laptopTotal.toFixed(2); } //--></script> <script language="JavaScript"><!-- function calculateTotalPurchaseDesktop(formRef) { var desktopTotal=0; for (var i=0; i<DesktopListPurchase.length/2;i++) { var subTotal = formRef.elements['quantity'+i].value * formRef.elements['price'+i].value; formRef.elements['subTotal'+i].value = subTotal.toFixed(2); desktopTotal += subTotal; } formRef.desktopTotal.value = desktopTotal.toFixed(2); } //--></script> <script language="Javascript"><!-- function checkform() { if (document.payment.Name.value == "") { alert('Please enter a name'); return false; } //else if(isNaN(document.payment.CreditCard.value) || document.payment.CreditCard.length !== 10) //{ // alert('Invalid Credit Card Number'); // return false; //} else if (document.payment.Adress.value == "") { alert('Please enter your adress.'); return false; } else if (document.payment.State.selectedIndex == 0) { alert('Please select a state'); return false; } return true; } </script> </HEAD> <BODY> <TITLE>Check Out</TITLE> <script> var html = ""; html += '<TABLE align="center"><tr><td><img src = "images/checkOutTitle.png" align="center" style="border:none" /></td></tr></TABLE>'; html += '<TABLE align = "center" border="2" cellpadding="2" cellspacing="2" width="80%">' html += '<form id = "orderForm" name = "orderForm" method = POST action="javascript:void(0)">'; html += '<tr>'; html += '<th>Product</th><th>Quantity</th><th>Price</th><th>Sub Total</th>'; html += '</tr>'; for (var i=0; i<LaptopListPurchase.length;i=i+2) { html += '<tr><td>' + LaptopListPurchase[i] + '</td>'; html += '<td><select NAME="quantity' + i/2 + '" onChange="calculateTotalPurchaseLaptop(this.form)">'; html += '<OPTION VALUE="0">0</OPTION><OPTION VALUE="1">1</OPTION><OPTION VALUE="2">2</OPTION>'; html += '<OPTION VALUE="3">3</OPTION><OPTION VALUE="4">4</OPTION><OPTION VALUE="5">5</OPTION>'; html += '</select></td>'; html += '<td>$<input type="text" name="price' + i/2 + '" size=5 value="' + LaptopListPurchase[i+1] + '" readonly></td>'; html += '<td>$<input type="text" name="subTotal' + i/2 + '" size=5 value="0.00" readonly></td>'; html += '</tr>'; } html += '<tr>'; html += '<td></td>'; html += '<td></td>'; html += '<td></td>'; html += '<td>$<input type=TEXT name="laptopTotal" value="" readonly size=7></td></tr>'; html += '</form>'; html += '</table>'; document.write(html); // Update the quantities // var quantityLaptop; for (var i=0; i<LaptopList.length/2;i++) { // Get the quantity of each type of Laptop // quantityLaptop = getCookie("Laptop" + i); document.orderForm.elements("quantity"+i).value = quantityLaptop; } // Update the totals // calculateTotalPurchaseLaptop(document.orderForm) var html = ""; html += '<TABLE align = "center" border="2" cellpadding="2" cellspacing="2" width="80%">' html += '<form id = "orderForm2" name = "orderForm2" method = POST action="javascript:void(0)">'; html += '<tr>'; html += '<th>Product</th><th>Quantity</th><th>Price</th><th>Sub Total</th>'; html += '</tr>'; for (var i=0; i<DesktopListPurchase.length;i=i+2) { html += '<tr><td>' + DesktopListPurchase[i] + '</td>'; html += '<td><select NAME="quantity' + i/2 + '" onChange="calculateTotalPurchaseDesktop(this.form)">'; html += '<OPTION VALUE="0">0</OPTION><OPTION VALUE="1">1</OPTION><OPTION VALUE="2">2</OPTION>'; html += '<OPTION VALUE="3">3</OPTION><OPTION VALUE="4">4</OPTION><OPTION VALUE="5">5</OPTION>'; html += '</select></td>'; html += '<td>$<input type="text" name="price' + i/2 + '" size=5 value="' + DesktopListPurchase[i+1] + '" readonly></td>'; html += '<td>$<input type="text" name="subTotal' + i/2 + '" size=5 value="0.00" readonly></td>'; html += '</tr>'; } html += '<tr>'; html += '<td></td>'; html += '<td></td>'; html += '<td></td>'; html += '<td>$<input type=TEXT name="desktopTotal" value="0.00" readonly size=7></td></tr>'; html += '<td></td>'; html += '<td></td>'; html += '<td align = "center"><b>Grand Total</b></td>'; html += '<td>$<input type=TEXT name="grandTotal" value="0.00" readonly size=7></td></tr>'; html += '</form>'; html += '</table>'; document.write(html); // Update the quantities // var quantityDesktop; for (var i=0; i<DesktopList.length/2;i++) { // Get the quantity of each type of Desktop // quantityDesktop = getCookie("Desktop" + i); document.orderForm2.elements("quantity"+i).value = quantityDesktop; } // Update the totals // calculateTotalPurchaseDesktop(document.orderForm2) </script> <table align = 'center'> <tr> <td><h1>Pay for your Purchase Below</h1></td> </tr> </table> <table border="1" align = 'center' > <form name="payment" method="post"> <tr> <td> Name on Credit Card: <input type="text" name="Name" /><br /> Credit Card number: <input type="text" name="CreditCard" /><br /> Street Adress: <input type="text" name="Adress" /><br /> Town: <input type="text" name="Town" /><br /> State/Territory: <select NAME="State"><OPTION VALUE="Null">--</OPTION><OPTION VALUE="Australian Capital Territory">ACT</OPTION><OPTION VALUE="South Australia">SA</OPTION><OPTION VALUE="Northen Territory">NT</OPTION><OPTION VALUE="Queensland">QLD</OPTION><OPTION VALUE="Victoria">Vic</OPTION><OPTION VALUE="Western Australia">WA</OPTION><OPTION VALUE="Tasmania">Tas</OPTION></select> </td> <td> <INPUT TYPE="RADIO" NAME="Master Card" VALUE="Master Card">Master Card<BR> <INPUT TYPE="RADIO" NAME="Visa" VALUE="Visa">Visa<BR> <INPUT TYPE="RADIO" NAME="AMEX" VALUE="American Express">American Express<BR> </td> </tr> <tr> <td></td> <td><input type="submit" value="Submit" onclick="return checkform()"></td> </tr> </table> </BODY> </HTML>[ /quote] hello everybody! this is my first atempt in writing javascript and i have a problem which I have no idea how to solve. I want to take the values from several dropdown forms and make some calculations whit those in order to display a number. Unfortunately the script responts in a way that i cannot identify what is happening. this is a shorten example of my script. Code: <html> <head> <script type="text/javascript"> function calcul() { var pcno = document.plithospc.listplpc.value; var ndno = document.plithosnd.listplnd.value; var hotline = document.hotlform.listhotl.value; var sumhotline = 0; if (hotline == 2) { sumhotline = 8*(1+0.5*pcno) + 2*(1+0.5*ndno); } else if (hotline == 3) { sumhotline = 16*(1+0.5*pcno) + 4*(1+0.5*pcno); } else { sumhotline = 0; } document.write(sumhotline); </script> </head> <body> <FORM NAME="plithospc"> <SELECT NAME="listplpc"> <OPTION SELECTED="SELECTED" VALUE=0>choose one</OPTION> <OPTION VALUE=1>-1-</OPTION> <OPTION VALUE=2>-2-</OPTION> <OPTION VALUE=3>-3-</OPTION> </SELECT> <FORM NAME="plithosnd"> <SELECT NAME="listplnd"> <OPTION SELECTED="SELECTED" VALUE=0>choose one</OPTION> <OPTION VALUE=1>-1-</OPTION> <OPTION VALUE=2>-2-</OPTION> <OPTION VALUE=3>-3-</OPTION> </SELECT> <FORM NAME="hotlform"> <SELECT NAME="listhotl"> <OPTION SELECTED="SELECTED" VALUE=0>choose one</OPTION> <OPTION VALUE=1>1st selection</OPTION> <OPTION VALUE=2>second selection</OPTION> <OPTION VALUE=3>third selection</OPTION> </SELECT> <button type="button" onclick="calcul()">click me</button> </body> does anyone knows how to fix this? thanks in advance Hi Coders, I have a javascript function which lets a user to choose one of the 7 option buttons on a "mainsub.asp" page and the page will then be forwarded to one of the 7 process pages depending on what has been chosen. The problem is that firefox is angry with the first line ("if" statement) and tells the following in its error console: Error: document.forms[0].C1 is not a function Source File: [localhost...] Line: 117 Here is the code: function fSubmit(){ if (document.forms[0].C1(0).checked) document.forms[0].action="process.asp"; else if (document.forms[0].C1(1).checked) document.forms[0].action="process1.asp"; else if (document.forms[0].C1(2).checked) document.forms[0].action="process2.asp"; else if (document.forms[0].C1(3).checked) document.forms[0].action="process3.asp"; else if (document.forms[0].C1(4).checked) document.forms[0].action="process4.asp"; else if (document.forms[0].C1(5).checked) document.forms[0].action="process5.asp"; else if (document.forms[0].C1(6).checked) document.forms[0].action="process6.asp"; else document.forms[0].action="process.asp"; return; } Internet explorer does not complain about anything and does its job great. But I could not figure out how to change the code to be also compliant with Firefox? Thanks for all the comments. What I am doing is working on a shooting app that will randomly call out different targets to shoot. I have it so it will randomly organize them but I need it so it pulls a single one. Any help would be appreciated! Code: <html> <body> <p id="demo">Click the Button to Call out a target</p> <button onclick="myFunction()">Call Out</button> <script type="text/javascript"> function myFunction() { var myarray=["red","blue", "yellow", "orange"] myarray.sort(function() {return 0.5 - Math.random()}) var x=document.getElementById("demo"); x.innerHTML=myarray; } </script> </body> </html> hi, I have this keypressed function: Code: function keyPressed(event, input) { if (event.keyCode == 8) { return true; } var char = event.which ? event.which : event.keyCode; char = String.fromCharCode(char); var exers = "1234 1234 1234"; return (exers.charAt(input.value.length) == char); } This function allow me to press in order the numbers in array (index0). It is works very well. But i want to add an array with more exercises like: Code: var exerc = new Array(); exerc[0]= "1234 1234 1234"; exerc[1] = "5678 5678 5678"; exerc[2] = "9012 9012 9012"; Also, i have a dropdown menu that parser options from a xml file: Code: <form> <select style="width:100px" id='courses'> </select> </form> and my xml file looks like: Code: <courses> <course title="exercise 1"> <lesson>1234 1234 1234</lesson> </course> <course title="exercise 2"> <lesson>5678 5678 5678</lesson> </course> <course title="exercise 3"> <lesson>9012 9012 9012</lesson> </course> . . . </courses> *I write the same index because i have two input field. I see the first choose (depend on dropdown) in first input, and i rewrite the same exercise in the second input. So, it's something like an exercise for me and i stack here. - I repeat. It is work with only one index very well. The problem is that, when i add more that one index in the array. Any suggestion about my problem?Javascript it is not my strong point I try this but it is doesn't work.Baybe it is totally wrong! Code: function keyPressed(event, input) { if (event.keyCode == 8) { return true; } var char = event.which ? event.which : event.keyCode; char = String.fromCharCode(char); var exerc = new Array(); exerc[0]= "1234 1234 1234"; exerc[1] = "5678 5678 5678"; exerc[2] = "9012 9012 9012"; for (i=0;i<exerc.length;i++) { document.getElementById("courses").selectedIndex; } return (exers.charAt(input.value.length) == char); } I've recently downloaded this Firefox plugin: https://addons.mozilla.org/en-US/fir...utofill-forms/ It has a feature called dynamic tags which do the following functions using Javascript: <datetime> new Date().toLocaleString() <useragent> navigator.userAgent <langcode> navigator.language <resolution> screen.width+'x'+screen.height <clipboard> this.getClipboardText() I was wondering if a JavaScript code exists that could get the value of "nation=" for links like the one below [url]http://m.nationstates.net/?nation=NATION_NAME_GOES_HERE Any help would be appreciated and if I'm off my rocker feel free to tell me so Hello, I have a tricky one here. What I have is a form where the user would enter in their food recipe. There is nothing clever in that until I need them to enter in the ingredients and the quantity into 2 seperate fields. The issue is that I don't know how many different ingredients there would be for the recipe so from within the form before the record is saved I need them to be able to fill out the 2 fields as many times as they need to (pressing a button each time) and I would have thought for the data to be held in a javascript array that i could then write away into the mysql table? I probably haven't made much sense. Can anyone help? Okay well here is my code. i want to mkae it so the functions add together to get a total price, i need some help Code: <html> <head> </head> <script type="text/javascript"> function addit(){ if(document.getElementById("add").value=="0") { document.getElementById("amount").value="$0.00" } if(document.getElementById("add").value=="1") { document.getElementById("amount").value="$5.00" } if(document.getElementById("add").value=="2") { document.getElementById("amount").value="$10.00" } if(document.getElementById("add").value=="3") { document.getElementById("amount").value="$15.00" } } function addit2(){ if(document.getElementById("add2").value=="4") { document.getElementById("amount").value="$30.00" } if(document.getElementById("add2").value=="5") { document.getElementById("amount").value="$40.00" } } </script> <body> <table class="comparison pricing-email" border="0" cellspacing="1" cellpadding="0" width="30%"> <tbody> <tr class="row1"> <td class="col1">Choose # of EMAIL accounts: <select style="width: 60px; font-size: 17px;" name="add" id="add" onChange="addit()"> <option value="0"> </option> <option value="1">1</option> <option value="2">3</option> <option value="3">6</option> </select> </td> </tr> <tr class="row2"> <td class="col2">Choose # of EMAIL accounts: <select style="width: 60px; font-size: 17px;" name="add" id="add2" onChange="addit2()"> <option value="0"> </option> <option value="4">44</option> <option value="5">43</option> <option value="3">342</option> </select> </td> </tr> <tr class="row1"> <td class="col1">Total Price: <input type="text" id="amount" value="" style="border:none; font-size:13pt;"></td> </tr><tr> <td> <input type="submit" name="submit" value="Sign-Up"> </td> </tr> </tbody> </table> </form> </body> Hi , I want to make few forms but 1 submit button. I want to do 1 page , 5 forms , 1 submit button so when i click on the submit button it will send the 5 forms as 1 form. how I can so that? thanks , Mor. Forgive me if this isn't in the right spot. I'm new at php and java so bear with me. I have small form I found and modified. This works as I wanted it to. Code: <HEAD> <SCRIPT LANGUAGE="JavaScript"> <!-- Begin function solveALK(form) { var alkalinity = eval(form.alkalinity.value); var alkneeds = eval(form.alkneeds.value); var change = (alkneeds) - (alkalinity); var add1 = (change) / (10) * (0.075) * (1.5) * (16); var add2 = (add1) / (16); form.alkchange.value = change; form.addoz.value = add1; form.addlbs.value = add2; } // End --> </script> </HEAD> <!-- STEP TWO: Copy this code into the BODY of your HTML document --> <BODY> <center> <table> <tr><td> </td> </tr> </table> <form method=post name=alkform> <table border=4> <tr> <td align=center> Alkalinity </td> <td align=center> <input type=text name=alkalinity size=3> </td> <td align=center> Needs to be: </td> <td align=center> <input type=text name=alkneeds size=3> </td> </tr> <tr> <td align=center> Change required: </td> <td colspan=3 align=center> <input type=text name=alkchange size=3> </td> </tr> <tr> <td align=center> Add this amount </td> <td colspan=3 align=center> <input type=text name=addoz size=3>oz </td> </tr> <tr> <td align=center> Add this amount </td> <td colspan=3 align=center> <input type=text name=addlbs size=3>lbs </td> </tr> <tr> <td colspan=4 align=center> <input type=button name=alk value="Calculate" onClick="javascript:solveALK(this.form)"> </td> </tr> </table> </form> </center> However when I put this into my php file, When I add my 2 figures to the input boxes. and click the calculate button, I get a NaN. I'm thinking it might be because I have 2 forms on my php page. One area of the page will update the database while this one would just calculate some figures. Here's the php page that doesn't seem to work. Code: <html> <head> <link rel="stylesheet" type="text/css" href="../style1.css" /> <title>Pool Log Report</title> <SCRIPT LANGUAGE="JavaScript"> <!-- Chemical calulations --> <!-- Begin function solveALK(form) { var alkalinity = eval(form.alkalinity.value); var alkneeds = eval(form.alkneeds.value); var change = (alkneeds) - (alkalinity); var add1 = (change) / (10) * (0.075) * (1.5) * (16); var add2 = (add1) / (16); form.alkchange.value = change; form.addoz.value = add1; form.addlbs.value = add2; } // End --> </script> </head> <body class="body"> <center> <table class="main1"> <?php include("update_header.php"); ?> <form action="updated.php" method="post" name="FormName"> <tr> <td class="main2"><input id="Dayid" name="Dayid" type="text" size="1" value="<?php echo $Dayid ?>" maxlength="2" readonly></td> <td class="main3"> </td> <td class="main3"><input id="patron_loading_max" name="patron_loading_max" type="text" size="1" value="<?php echo $patron_loading_max ?>" maxlength="2"></td> <td class="main3"><input id="patron_loading_24hr" name="patron_loading_24hr" type="text" size="1" value="<?php echo $patron_loading_24hr ?>" maxlength="2"></td> <td class="main3"><input id="water_clearity__clear" name="water_clearity__clear" type="checkbox" <?php if ($water_clearity__clear == "X") { echo "checked";} ?> value="X"></td> <td class="main3"><input id="water_clearity__turbid" name="water_clearity__turbid" type="checkbox" <?php if ($water_clearity__turbid == "X") { echo "checked";} ?> value="X"></td> <td class="main3"><input id="water_temp" name="water_temp" type="text" size="1" value="<?php echo $water_temp ?>" maxlength="3"></td> <td class="main3"><input id="psi" name="psi" type="text" size="1" value="<?php echo $psi ?>" maxlength="3"></td> <td class="main3"><input id="gpm" name="gpm" type="text" size="1" value="<?php echo $gpm ?>" maxlength="3"></td> <td class="main3"><input id="drain_back" name="drain_back" type="text" size="1" value="<?php echo $drain_back ?>" maxlength="5"></td> <td class="main3"><input id="chlorine_am1" name="chlorine_am1" type="text" size="1" value="<?php echo $chlorine_am1 ?>" maxlength="5"></td> <td class="main3"><input id="chlorine_am2" name="chlorine_am2" type="text" size="1" value="<?php echo $chlorine_am2 ?>" maxlength="5"></td> <td class="main3"><input id="ph_am1" name="ph_am1" type="text" size="1" value="<?php echo $ph_am1 ?>" maxlength="5"></td> <td class="main3"><input id="ph_am2" name="ph_am2" type="text" size="1" value="<?php echo $ph_am2 ?>" maxlength="5"></td> <td class="main3"><input id="chlorine_pm1" name="chlorine_pm1" type="text" size="1" value="<?php echo $chlorine_pm1 ?>" maxlength="5"></td> <td class="main3"><input id="chlorine_pm2" name="chlorine_pm2" type="text" size="1" value="<?php echo $chlorine_pm2 ?>" maxlength="5"></td> <td class="main3"><input id="ph_pm1" name="ph_pm1" type="text" size="1" value="<?php echo $ph_pm1 ?>" maxlength="5"></td> <td class="main3"><input id="ph_pm2" name="ph_pm2" type="text" size="1" value="<?php echo $ph_pm2 ?>" maxlength="5"></td> <td class="main3"><input id="combined_chl" name="combined_chl" type="text" size="1" value="<?php echo $combined_chl ?>" maxlength="4"></td> <td class="main3"><input id="alkalinity" name="alkalinity" type="text" size="1" value="<?php echo $alkalinity ?>" maxlength="3"></td> <td class="main3"><input id="chemicals_add" name="chemicals_add" type="text" size="1" value="<?php echo $chemicals_add ?>" maxlength="55"></td> <td class="main3"><input id="chemicals_qty" name="chemicals_qty" type="text" size="1" value="<?php echo $chemicals_qty ?>" maxlength="55"></td> <td class="main3"><input id="super_oxidation" name="super_oxidation" type="text" size="1" value="<?php echo $super_oxidation ?>" maxlength="3"></td> <td class="main4" class="main3"> </td> </tr> <tr> <td class="main4" colspan="24"> </td> </tr> <form method=post name=alkform> <tr> <td class="main2" colspan="3"> </td> <td class="main2" colspan="5"><b>Whirlpool Calculations</b></td> <td class="main2" colspan="5"> </td> <td class="main2" colspan="5"><b>Chlorine Shocking</b></td> <td class="main2" colspan="2"><b>FAS-DPD</b></td> <td class="main2" colspan="3"><b>Chlorine No-Shock</b></td> <td class="main2"> </td> </tr> <tr> <td class="main4" rowspan="3" colspan="3"> </td> <td class="main2" colspan="2">Alkalinity</td> <td class="main2"><input type=text name=alkalinity size=3></td> <td class="main2" colspan="2"> </td> <td class="main2" colspan="2">Calcium</td> <td class="main2"><input id="Calcium" name="Calcium" type="text" size="1" value="<?php echo $Calcium ?>" maxlength="3"></td> <td class="main2" colspan="2"> </td> <td class="main2" colspan="3">Drops</td> <td class="main2"><input id="R0871_drops" name="R0871_drops" type="text" size="1" value="<?php echo $R0871_drops ?>" maxlength="3"></td> <td class="main2" colspan="2">Breakpoint</td> <td class="main2"><?php echo $Breakpoint ?></td> <td class="main2" colspan="2">Needs to be:</td> <td class="main2"><input id="Chl_Needs" name="Chl_Needs" type="text" size="1" value="<?php echo $Chl_Needs ?>" maxlength="3"></td> <td class="main4" rowspan="3"> </td> </tr> <tr> <td class="main2" colspan="2">Needs to be:</td> <td class="main2"><input type=text name=alkneeds size=3></td> <td class="main2">Change:</td> <td class="main2"><input type=text name=alkchange size=3></td> <td class="main2" colspan="2">Needs to be:</td> <td class="main2"><input id="Cal_Needs" name="Cal_Needs" type="text" size="1" value="<?php echo $Cal_Needs ?>" maxlength="3"></td> <td class="main2"">Change:</td> <td class="main2"><?php echo $Cal_Change ?></td> <td class="main2" colspan="3">Free Chl</td> <td class="main2"><?php echo $Free_Chl ?></td> <td class="main2">ppm</td> <td class="main2" colspan="2">Amt to shock</td> <td class="main2" colspan="2">Change Required</td> <td class="main2"><input id="Chl_Change" name="Chl_Change" type="text" size="1" value="<?php echo $Chl_Change ?>" maxlength="3" readonly></td> </tr> <tr> <td class="main2" colspan="3">Add Sodium BiCarb</td> <td class="main2"><input type=text name=addoz size=3></td> <td class="main2">Oz</td> <td class="main2" colspan="3">Add Calcium</td> <td class="main2"><?php echo $Cal_Add_oz ?></td> <td class="main2">Oz</td> <td class="main2" colspan="3">Drops</td> <td class="main2"><input id="R0003_drops" name="R0003_drops" type="text" size="1" value="<?php echo $R0003_drops ?>" maxlength="3"></td> <td class="main2"> </td> <td class="main2"><?php echo $AmtShk_oz ?></td> <td class="main2">oz</td> <td class="main2" colspan="2">Add this in oz</td> <td class="main2"><input id="Chl_Add" name="Chl_Add" type="text" size="1" value="<?php echo $Chl_Add ?>" maxlength="3"></td> </tr> <tr> <td class="main4" colspan="6"> </td> <td class="main2"><input type=text name=addlbs size=3></td> <td class="main2">Lbs</td> <td class="main2" colspan="3"> </td> <td class="main2"><?php echo $Cal_Add_lbs ?></td> <td class="main2">Lbs</td> <td class="main2" colspan="3">Combined Chl</td> <td class="main2"><?php echo $Comb_Chl ?></td> <td class="main2">ppm</td> <td class="main2"><?php echo" ".number_format($AmtShk_gal,2); ?></td> <td class="main2">Gal</td> <td class="main4" colspan="6"> </td> </tr> <tr> <td colspan="24" align="center" class="main2">Make your changes and click the update button below.</td> </tr> <tr> <td colspan="24" align="center" class="main2"><input type=button name=alk value="Calculate" onClick="javascript:solveALK(this.form)"></form> <input type="button" value="Update" onclick="this.form.action='updated.php'; this.form.submit();"><input type="hidden" name="id" value="id"> <INPUT TYPE="button" VALUE="Back" onClick="history.go(-1);return true;"></td> </tr> </table> </form> </center> If I am correct that I need to separate the forms. How do I do so? Or am I going about this wrong? Hey I was hoping someone could help me. I have written a form in HTML. But it is very long - I would like to make it a Tabbed form so that at the top there is tabs for each section to make it more managable and less intimidating. I figured it was probably Javascript - but I don't know JS so I was wondering what I would have to do for that form to be made? Is there a predefined function or something or does anyone know how to code a form like that? Regards, Angelous I'm right at the beginning of learning javascript and having trouble with my first project Code: <html> <head> </head> <body> <form onsumbit="return add_hq()"> Headquarters: <select name="ork_hq_list" id="ork_hq_list" > <option value="warboss.html">Warboss<br /> <option value="big_mek.html">Big Mek<br /> <option value="weirdboy.html">Weirdboy<br /> </select> <input type="submit" value="Add"/> </form> <script type="text/javascript"> function add_hq() { hq = document.getElementById("ork_hq_list"); window.open("hq.options[hq.selectedIndex].value","Warboss","width=700"); return false; }; </script> </body> </html> Basically I have a 3 element drop-down form that is supposed to pop up a small window depending on what choice is selected when the submit button is pressed, but the selection is not getting to the code somehow. Can anyone see what I've done wrong? I am trying to take the add the numbers input into form boxes 1 and 2 and then output them onto the screen following the form boxes. I have tried many different functions and none of them will work. Can anyone point me in the right direction? Here's my code so far: 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=iso-8859-1" /> <title>Math and Compare</title> <link rel="stylesheet" type="text/css" href="assignment1.css" /> <div align="center"> <script type="text/javascript"> var title = "<strong>Assignment 1 </br> Aughtman, Zackary</strong>" document.write(title.fontsize(5)); </script> <script type="text/javascript"> function result_One(firstNum, secondNum, result1) { firstNum = document.getElementById("box1").value; secondNum = document.getElementById("box2").value; result_One = this.firstNum + this.secondNum; return calc.result_One; } </script> </head> <body> </br> </br> <div id="div1" align="center"> <strong>Addition</strong> </div> <table align = "center"> <tr> <td> <form id="box1"> <input type="text" value="" id="box1" class="box1" /> + <input type="text" value="" id="box2" class="box2" /> = 000000000 </br> <div align="center"> <input type="button" value="Add" id="add" onclick="result_One;" /> </td> </tr> </table> </body> </html> When I click Vacant after 5 and it goes to occupied. How would I make it come back to vacant when clicked again? Code: <html> <head> <script type="text/javascript"> function fillForm() { if (counter > 10){ } } </script> <script type="text/javascript"> function StartCounting(){ setInterval("DoCounting()", 1000) } var Counter = 0; function DoCounting(){ var obj = document.getElementById('countingtext'); obj.innerHTML = '' + Counter; Counter++; if( Counter > 5) { var obj1 = document.getElementById("closed").value = "Open"; var space1 = document.getElementById("space1") space1.onclick = linkClick; } } function linkClick(){ space1 = document.getElementById("space1").value = "Occupied"; } </script> </head> <body onload= "StartCounting()"> Open at 5: <span id="countingtext"></span> </body> </html> <div style="margin-right:3mm; " > <form action="#" method="post" id="theForm" > <input size="10" id="closed" value="Closed" style="text-align:center;" /> <script type="text/javascript"> </script> <input type='button' id="space1" name='s"+ i+"' value='Vacant' onclick='readSpace(s"+ i+")' style='width:15mm;' /></td> </form> </div> I am trying to set up a form for paypal where the amount (cost) of the product is based on the currency chosen. I am trying to set this up using javascript which would submit the form and change the amount in the form. However, as a beginner, I am having some issues. This is what I have currently: Code: <html> <head> <script type="text/javascript"> function CalculateOrder(theform) { var currency = theform.currency_code.value; if (currency == "GBP") { theform.amount.value = "1.29" } else if (currency == "USD") { theform.amount.value = "1.99" } else if (currency == "EUR") { theform.amount.value = "1.39" } document.payform.submit(); } </script> </head> <body> <form target="paypal" action="https://www.paypal.com/cgi-bin/webscr " method="post" name="payform"> <input type="hidden" name="on0" value="Currency"> <select name="currency_code"> <option value="GBP" selected >GBP</option> <option value="USD">USD</option> <option value="EUR">EUR</option> </select> </p> <input type="image" src="https://www.paypal.com/en_US/i/btn/btn_buynowCC_LG.gif " onClick="CalculateOrder(this.form)" alt="Make payments with PayPal - it's fast, free and secure!"> <input type="hidden" name="add" value="1"> <input type="hidden" name="cmd" value="_xclick"> <input type="hidden" name="business" value="myemail@gmail.com"> <input type="hidden" name="item_name" value="My Prouct"> <input type="hidden" name="amount" value="0.00"> <input type="hidden" name="shipping" value="0"> <input type="hidden" name="no_shipping" value="1"> </form> </fieldset> </body> </html> The javascript is executed but clicking the image submits the form before the javascript runs and I am worried that the javascript may not run before the form is submitted so the amount would not be calculated - please help! I do not want to calculate the costs based on the exchange rate. I would really prefer (and also find it simpler) to just specify the cost in each currency. Thanks in advance! Hi all - I'm having difficulty with the processing of 3 forms on my web page. We'll call my 3 forms A, B, and C. By default my page shows form A. The other 2 forms I have hidden via display:none My issue is when I have form B or C showing. Once I hit submit, say within form B for example, I'd like this form to remain for future entries/submital of data. However, instead what happens is form A appears. How do I get form B to remain, allowing for a user to submit multiple entries of data without going back to form A? Here's my code for form 'B' <div id="branches_info" style=" <?php echo $display_branches; ?> "> form method="post" action="annual_report_main.php" onsubmit="return validateBranches(this);"> <fieldset> <p><strong>Branch Location</strong></p><br /> <label for="branch_address" class="long">Street Address:</label> <input maxlength="50" type="text" name="branch_address" id="branch_address" value="<?php echo htmlentities($_POST['branch_address']);?>" /><br /> <div class="cleaner"></div> <label for="branch_city" class="long">City:</label> <input maxlength="20" type="text" name="branch_city" id="branch_city" value="<?php echo htmlentities($_POST['branch_city']);?>" /><br /> <div class="cleaner"></div> <label for="branch_state" class="long">State:</label> <input maxlength="2" type="text" name="branch_state" id="branch_state" value="<?php echo htmlentities($_POST['branch_state']);?>" /><br /> <div class="cleaner"></div> <label for="branch_zip" class="long">Zip Code:</label> <input maxlength="10" type="text" name="branch_zip" id="branch_zip" value="<?php echo htmlentities($_POST['branch_zip']);?>" /><br /> <div class="cleaner"></div> <div class="content_onecolumn"> <input type="submit" name="Branches" value="Submit to Database" class="inputSubmit" /> </div> <div class="content_onecolumn"> <input type="button" name="Finished" value="Finished" class="inputSubmit" onclick="window.open('https://www.dca.ca.gov/webapps/bppe/thankyou.php');return false" /> </div> </fieldset> </form> </div> Hello. I am using javascript to create a dynamic form to allow me to add multiple items to the form before posting... this is the code: Code: if (!$_POST) { ?> <title>Adding elements to a form</title> <form name="form1" enctype="multipart/form-data" action="" method="post"> <div ID="Items"> <b>Dog 1:</b> <input type="text" name="Item1" size="45"> <br> <input type="button" value="Add Item" onClick="AddItem();" ID="add"> <input type="submit" name ="submit" value="Submit Form" > </div> </form> <? } else { echo print_r ($_POST); } ?> <script language="javascript"> var items=1; function AddItem() { div=document.getElementById("Items"); button=document.getElementById("add"); items++; newitem="<b>Dog " + items + ": </b>"; newitem+="<input type=\"text\" name=\"Item" + items ; newitem+="\" size=\"45\"><br>"; newnode=document.createElement("span"); newnode.innerHTML=newitem; div.insertBefore(newnode,button); } </script> It works but each element in the printed post array shows as Item1, Item2 etc with each being a seperate array... How can I make it so that I have a single posted array called Item with that array then having elements Item[1] etc up to the number of elements I add... Any help would be appreciated |