JavaScript - Trying To Get Amount In Taxbox Checked To Revert To 0.00 When Unchecked
Hello,
I am a total newbie, so forgive me in advance as I am just learning javascript. I am putting together a small order form and the javascript code adds the tax (.0825) and shipping (if any - entered by user) to the subtotal. But when I uncheck it, the taxamt amount stays in the box. Any ideas on how to have the taxamt back to 0 when unchecked. Code: <form name= "placeOrder"> <table width="70%" border="1" cellpadding="5" cellspacing="5" bordercolor="#e2e2e2"> <tr> <td>fabric number</td> <td>yardage</td> <td>price</td> <td>amount</td> <td>sample size</td> </tr> <tr> <td align="center"><input name="fab1" type="text" id="fab1"></td> <td align="center"> <input type = "text" name = "qty1" id = "qty1" onchange = "doMath(1)"></td> <td align="center"> <input type = "text" name = "cost1" id = "cost1" onChange = "doMath(1)"></td> <td align="center"><input type = "text" name = "amount1" id = "amount1" value = "0.00" readonly></td> <td align="center"><input name="sample1" type="text" id="sample1"></td> </tr> <tr> <td align="center"><input name="fab2" type="text" id="fab2"></td> <td align="center"><input type = "text" name = "qty2" id = "qty2" onChange = "doMath(2)"></td> <td align="center"><input type = "text" name = "cost2" id = "cost2" onChange = "doMath(2)" ></td> <td align="center"><input type = "text" name = "amount2" id = "amount2" value = "0.00" readonly></td> <td align="center"><input name="sample2" type="text" id="sample2"></td> </tr> <tr> <td align="center"><input name="fab3" type="text" id="fab3"></td> <td align="center"><input type = "text" name = "qty3" id = "qty3" onChange = "doMath(3)"></td> <td align="center"><input type = "text" name = "cost3" id = "cost3" onChange = "doMath(3)"></td> <td align="center"><input type = "text" name = "amount3" id = "amount3" value = "0.00" readonly></td> <td align="center"><input name="sample3" type="text" id="sample3"></td> </tr> <tr> <td height="31"> </td> <td> </td> <td align="right">Texas sales tax <input type="checkbox" id="taxbox" name="taxbox" onclick="doMath(1)"> </td> <td align="center"><input type="text" name="taxamt" id="taxamt" value="0.00" onChange="doMath()"></td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td align="right">subtotal:</td> <td align="center"><input type="text" name="GdTotal" value="0.00" id="GdTotal" readonly></td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td align="right">shipping & handling:</td> <td align="center"><INPUT type="text" id="shipamt" value="0.00" name="shipamt" onChange="doMath()"> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td>invoice will be emailed when shipping cost is calculated</td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td align="right">Total:</td> <td><input type="text" name="GdTotal" value="0.00" id="GdTotal" readonly></td> <td> </td> </tr> </table> </form> <script type='text/javascript'> function doMath(which){ var gdtot = 0; var tx //" Excluding TX Sales tax"; var units = document.getElementById("qty"+which).value; var shipamt = document.getElementById("shipamt").value; shipamt = parseFloat( shipamt ); if (isNaN(units)) { document.getElementById("qty"+which).value = ""} if (isNaN(shipamt)) { document.getElementById("shipamt").value = ""; shipamt = 0; // so no error when added to gdtot } var rate = document.getElementById("cost"+which).value; var total = units * rate; if(!isNaN(total)) { var total2dp = total.toFixed(2); document.getElementById("amount"+which).value = total2dp; for (var i = 1; i <=3; i++) { x = document.getElementById("amount" + i).value; gdtot = +x +gdtot; // ensure x is a number } if (document.getElementById("taxbox").checked) { var taxamt = gdtot * 0.0825; document.getElementById("taxamt").value = taxamt.toFixed(2); gdtot += taxamt; } gdtot += shipamt; document.getElementById("GdTotal").value = gdtot.toFixed(2); } } </script> Similar TutorialsI use a JavaScript form field validator; I have some multi-select checkboxes on a form (check as many that apply). For instance, if you tick the box that says you have a car, it requires you to list list the "Model" in another form field. This works: Code: function formCheckCar(formobj) { if ( formobj.elements['Car].checked && formobj.elements['Model'].value == '' ) { alert('Error: Provide model of your car'); return false; } return true; } How would I modify this if I wanted the alert triggered if the checkbox was NOT ticked? I took a few stabs at it, tired this: Code: if ( formobj.elements['Car].unchecked and Code: if ( formobj.elements['Car].!=checked No dice. Thank you. I am trying to get the images on this page to revert back to the original photo after hover releases. I am assuming this is a simple fix, but I am no programmer and just did this in dreamweaver. http://www.dataflurry.com/joey/ when user populate info it will appear like this: ------------------------- chkbox | name | number ------------------------- radbtn | MJ | 234123 radbtn | MD | 343543 radbtn | AB | 453466 Is uncertain that how many info will appear as its from database. I am able to enable the radbtn with chkbox by getting radbtn name. How can i enable only the selected radbtn textbox under name and number in order for user to edit it ? thanks anyone who can solve it! Hi, I have a form setup so that selecting a radio button opens a specific text field. The problem is if the user starts to enter information, then switches to a different radio button (perhaps they chose the wrong radio to start), the text they already started to enter on the previous textfield doesn't get cleared. This will be a problem later when inserting to sql. Here is a summary of the code: Code: <head> <script type="text/javascript"> function doClick(objRad){ if (objRad.value=="0"){ document.getElementById("textbox").style.display='block'; } else{ document.getElementById("textbox").style.display='none'; } if (objRad.value=="1"){ document.getElementById("textbox1").style.display='block'; } else{ document.getElementById("textbox1").style.display='none'; } if (objRad.value=="2"){ document.getElementById("textbox2").style.display='block'; } else{ document.getElementById("textbox2").style.display='none'; } } </script> </head> <body> <form action="insert.php" method="post"> <p>Please choose the business type: <input type="radio" name="rad" value="0" onclick="doClick(this)"> Sole Proprietorship <input type="radio" name="rad" value="1" onclick="doClick(this)"> Partnership <input type="radio" name="rad" value="2" onclick="doClick(this)"> Corporation <div id="textbox" style="display:none"> <input type="text" name="txt"> This is my sole proprietorship info.</div> <div id="textbox1" style="display:none"> <input type="text" name="txt"> This is my partnership info.</div> <div id="textbox2" style="display:none"> <input type="text" name="txt">This is my corporation info. </div> </form> </body> Any help is appreciated, Thanks in advance! This is probably a really simple question. Is it possible to initialize x amount of variables. Like someone enters 10 into an input box and it makes 10 variables called variable1, variable2, variable3, etc. How would you name them? variable + num = 0; ? Thanks! Hi is there a way to only allow a certain numeric amount to be entered into a text input? i.e, Like nothing over 20? Thanks Hi, I am thinking of how to write the code for this: There are 4 textboxes, 3 of which allow you to enter any number (e.g. 1000, 2500, 12345, 100.10, etc.). So whenever I entered a number in one of them (or two or all of them), the 4th read-only textbox will automatically shows the total of the values in the 3 textboxes. So...can anyone give me any references to this? Thanks. I have a text field. I want the text field to change / be calculated on the action made on the dropdown menu... So if I select Debit card.. it should leave the amount as is.. If I selected Credit Card it should add a percentage to the Amount. Please dont just provide a solutoin.. but please explain as i would love to understand why 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 type="text/javascript"> function doMath() { if (CardType = "cc") { var one = eval(document.myForm.Amount.value) var prod = one * 1.03 document.myForm.Amount.value=custRound(prod,2);} } else document.myForm.Amount.value; function custRound(x,places) { return (Math.round(x*Math.pow(10,places)))/Math.pow(10,places) } </script> </head> <body> <form id="myForm" name="myForm" method="post" action=""> <input name="Amount" type="text" id="Amount" v alue="100" /> <select id="CardType" name="CardType" onchange="doMath();" > <option value="" selected="selected">Please Select</option> <option value="dc">Debit Card</option> <option value="cc">Credit Card</option> </select> </form> </body> </html> Hey guys. So I've been learning PHP and MySQLi for the past few weeks and it's going brilliantly! I intend to start learning JS over the Xmas holidays, but right now I only have a very basic knowledge of it. I was just wondering if someone could point me in the right direction on how to do this, as I think i should be pretty easy. After someone changes something in the admin area [e.g. the position of an item] I want to be able to have a small div display at the top of the screen saying something like "Position Updated!" and then have it fade away after 2-3 seconds. Just wondering if there's a fairly easy way to do this, or would I have to go get something like MooTools, etc.? Thanks a lot! Hi, i followed a tutorial online on how to use Javascript to calculate total price. Everything works fine, when all the dropdown select value has it's own value and does not correspond to each other. Eg : Cake Type : Round $4.00 Cake Color : Red $3.00 Cake Filling : Raspberry $4.00 So total is $11.00 The problem comes when you want to add Cake Layers and the price of Cake Color changes based on No of Layers - 1 Layer , 2 Layer and so on. Eg: Cake Layer : Layer 1 $5.00 | Layer 2 $2.50 | Layer 3 $2.50 (for color Orange) Cake Layer : Layer 1 $7.00 | Layer 2 $4.00 | Layer 3 $4.00 (for color Red) Do i have to use if and else conditional statement for every possibility? I am just a beginner. Attached below is the example code i have so far.. Code: var filling_prices= new Array(); filling_prices["None"]=0; filling_prices["Lemon"]=5; filling_prices["Custard"]=5; filling_prices["Fudge"]=7; filling_prices["Mocha"]=8; filling_prices["Raspberry"]=10; function getFillingPrice() { var cakeFillingPrice=0; //Get a reference to the form id="cakeform" var theForm = document.forms["cakeform"]; //Get a reference to the select id="filling" var selectedFilling = theForm.elements["filling"]; //set cakeFilling Price equal to value user chose //For example filling_prices["Lemon".value] would be equal to 5 cakeFillingPrice = filling_prices[selectedFilling.value]; //finally we return cakeFillingPrice return cakeFillingPrice; } This is for the calculation Code: function calculateTotal() { //Here we get the total price by calling our function //Each function returns a number so by calling them we add the values they return together var cakePrice = getCakeSizePrice() + getFillingPrice() + candlesPrice(); //display the result var divobj = document.getElementById('totalPrice'); divobj.style.display='block'; divobj.innerHTML = "Total Price For the Cake $"+cakePrice; } Some sample of the HTML Code: <select id="filling" name='filling' onchange="calculateTotal()"> <option value="None">Select Filling</option> <option value="Lemon">Lemon($5)</option> <option value="Custard">Custard($5)</option> <option value="Fudge">Fudge($7)</option> <option value="Mocha">Mocha($8)</option> <option value="Raspberry">Raspberry($10)</option> Is there a better way of simplifying this calculation method ? How do i change the price of form values based on selected values on previous dropdown. Thanks in advance. So if I have three dollar amounts like .... a = 1,222.00; b = 1,323.00; c = ; d = 1,222.00; How can I alert the highest variable even though there may be 1 or more of them? So I have a form. Unfortunately, I'm not using a <form> tag, it's all div. Code: <div id="mainForm"> <div class="label"><input type="checkbox" id="LeftFixed" />Left Bar Always On Screen</div> What I'm trying to do is if that box is checked, execute a javascript. How do I do that? so if checked, execute 'sources/leftbar.js' or I could even just copy the code so it's inline, and not called. Is there a way to do this? This is my table which the user will see. When the user select a category, the table will show the result. Therefore the number of row of details that will be shown is uncertain. Over here i show 3 example. ------------------------- Edit | Name | Number | ------------------------- radbtn | John | 123456 | radbtn | MJ | 654321 | radbtn | JP | 443224 | I have a edit button. Once i click on it all my N amount of radio button will be enable. How can i do it? the problem is i have to hard code it [0] [1] [2], how can i change it to N? document.formname.btnname[0].disabled=false; thanks for helping anyone! Beginner JavaScripter here. I'm wanting to run a piece of code (add rows) a specified amount of times based upon the number selected. Also, rows can be added after initial number has been specified. Example: User1 selects 2 -> 2 rows are added User1 goes back and selects 3 -> 1 row is added, making 3 rows total I've tried the following, but it seems to not take into account the number of rows already added. Any help is appreciated. Code: if (numSelected > 0) { var counter = 0; while (rowsAdded < numSelected ) { function.addRow(); counter++; } } I have this code which converts Fahrenheit to Celsius. Now, I have to have a counter that displays the amount of times I have made a conversion. I have no clue how to do this. This is the initial code:
Code: <html> <head> <script type="text/javascript"> /* Converts given centigrade in one text box to farenheit in another */ function convert1 () { document.getElementById("output").value = document.getElementById("input").value*1.8+32; } </script> </head> <body> <p>Then enter the input and view the output</p> <input type="text" size="15" id="input"> <input type="button" value=" ==> " onclick="convert1()"> <input type="text" size="15" id="output"> </body> </html> I don't know how to approach this so I tried different things.... Code: tml> <head> <script type="text/javascript"> /* Converts given centigrade in one text box to farenheit in another */ function convert1 () { document.getElementById("output").value = document.getElementById("input").value*1.8+32; } function counter() { if (function convert1().onclick==true) {count++;} } </script> </head> <body> <p>Then enter the input and view the output</p> <input type="text" size="15" id="input"> <input type="button" value=" ==> " onclick="convert1()"> <input type="text" size="15" id="output"> </body> </html> but then I did some research and it said I couldn't do that.... so I tried this: Code: <html> <head> <script type="text/javascript"> /* Converts given centigrade in one text box to farenheit in another */ var count=0; function documentClick() { document.getElementById('clicked').value = ++clickCount } document.onclick = documentClick; function convert1 () { document.getElementById("output").value = document.getElementById("input").value*1.8+32; } </script> </head> <body> <p>Then enter the input and view the output</p> <input type="text" size="15" id="input"> <input type="button" value=" ==> " onclick="convert1()"> <input type="text" size="15" id="output"> </body> </html> I think this last code is correct, the problem I have now is that I don't know how to call it to just display as text under the buttons and conversions. I'm looking for some way to display it like ("you have made"+ count+ "conversions");. No boxes or buttons, just text and I don't know how to call for this after the </script>, inside the body. I am new at all this and would appreciate any help. Thanks. It should look like this. How do you make an image begin to load after a certain amount of time? e.g 3 seconds.
I need some help on my math equation, I got the calculations and confirm.submit, and the alert messages to all work properly, but when I go to put the data into the math equation, I am coming up with some outrageous number way off from what it is supposed to be. What I am trying to accomplish is to take the calculated number of day and hours and minutes; multiply the total time in hours by the equipment cost per hour and calculate the total amount of rent. My problem I think is in the calculate total amount of rent section in the script. Please help, your expertise is greatly appreciated. Below is the math equation in the script section: Code: //calculate days from date field function checkit() { var today = new Date(); var nowyear = today.getFullYear(); var d1 = document.forms[0].pickupDate.value.split("/"); var yr = d1[2]; var mm = d1[0]-1; var dy = d1[1]; var OK1 = checkValidDate(yr,mm,dy); if ((yr < nowyear || yr > nowyear +1)) {OK1 = false} // only valid for current year and next year var d2 = document.forms[0].returnDate.value.split("/"); yr = d2[2]; mm = d2[0]-1; dy = d2[1]; var OK2 = checkValidDate(yr,mm,dy); if ((yr < nowyear || yr > nowyear+2)) {OK2 = false} if ((!OK1) || (!OK2)) { alert ("Invalid dates\(s\) or incorrect format! Please try again."); document.forms[0].pickupDate.value = ""; document.forms[0].returnDate.value = ""; return false; } // arbitrary or example start and end times obtained from elsewhere (select lists) var fhrs = parseFloat(document.forms[0].pickupHours.value); var fmins = parseFloat(document.forms[0].pickupMinutes.value); var shrs = parseFloat(document.forms[0].returnHours.value); var smins = parseFloat(document.forms[0].returnMinutes.value); var firstDate = new Date(d1[2],d1[0]-1,d1[1],fhrs,fmins); // note month must be 0-11!! Also note USA date format var secondDate = new Date(d2[2],d2[0]-1,d2[1],shrs,smins); var difference = secondDate.getTime() - firstDate.getTime(); var secs = difference/1000; var days = Math.floor(secs/86400); secs %= 86400; var hours= Math.floor(secs/3600); if (hours<10) {hours = "0" + hours} secs %= 3600; var mins = Math.floor(secs/60); if (mins<10) {mins = "0" + mins} alert ("Time Difference is " + days + " Days " + hours + " Hours " + mins + " Minutes"); //calculate total amount of rent var equip = parseFloat(document.forms[0].equipment.value); var total = (((days * 24) + hours + mins) * equip); var OK = window.confirm(" The total rental cost is $" + total + "\n Click OK to accept, Cancel to decline"); if (OK) {return true} else {return false} } function checkValidDate(yr,mm,dy) { var nd = new Date(); nd.setFullYear(yr,mm,dy); // YYYY,MM(0-11),DD var ndmm = nd.getMonth(); if (ndmm != mm) { return false; } else { return true; } } This is the form in the body section: Code: <form onsubmit = "return validateForm()" action = "mailto:rogalskibf@gmail.com?subject=ABC Customer Reservation" method="post" enctype="text/plain"> <table border = "0"> <tr> <td> Equipment:<br/> <select name = "equipment"> <option value="unselected">Select Equipment Type</option> <option value = 20>Fishing Boat</option> <option value = 15>Kayak</option> <option value = 2>Mountain Bike</option> <option value = 10>Scuba Gear</option> </select> </td> </tr> <tr> <td> Pick-up Date: <br/> <input type = "text" id = "dateIn" name = "pickupDate" id = "date1" onchange = checkValidPDate(this.value)> </td> <td> Pick-up Time: <br/> <select name = "pickupHours"> <option value="unselected">hr</option> <option value = 7>07</option> <option value = 8>08</option> <option value = 9>09</option> <option value = 10>10</option> <option value = 11>11</option> <option value = 12>12</option> <option value = 13>13</option> <option value = 14>14</option> <option value = 15>15</option> <option value = 16>16</option> <option value = 17>17</option> </select> <select name = "pickupMinutes"> <option value="unselected">min</option> <option value = 0>00</option> <option value = .5>30</option> </select> </td> </tr> <tr> <td> Return Date: <br/> <input type = "text" id = "dateOut" name = "returnDate" id = "date2" onchange = checkValidRDate(this.value)> </td> <td> Return Time: <br/> <select name = "returnHours"> <option value="unselected">hr</option> <option value = 7>07</option> <option value = 8>08</option> <option value = 9>09</option> <option value = 10>10</option> <option value = 11>11</option> <option value = 12>12</option> <option value = 13>13</option> <option value = 14>14</option> <option value = 15>15</option> <option value = 16>16</option> <option value = 17>17</option> </select> <select name = "returnMinutes"> <option value="unselected">min</option> <option value = 0>00</option> <option value = .5>30</option> </select> </td> </tr> <tr> <td> First Name: <br/> <input type = "text" name = "firstName"/> </td> <td> Last Name: <br/> <input type = "text" name = "lastName"/> </td> </tr> <tr> <td> Street: <br/> <input type = "text" name = "street"/> </td> <td> City: <br/> <input type = "text" name = "city"/> </td> <td> Zip:<br/> <input type = "text" name = "zip" maxlength = "5"/> </td> </tr> <tr> <td> Date of Birth: <br/> <input type="text" name="date" onblur="checkAge(this.value)" /> </td> </tr> <tr> <td colspan = "3" align = "center"> <input type = "submit" name = "submit" value = "Submit Reservation" onclick = "return checkit()"/> <input type = "button" value = 'Set Cookies' onclick = "setCookie('anyName', cookieValue ,expDate)"> <input type = "button" value = 'Display Cookies' onclick = "dispCookie('anyName')"> </td> </tr> </table> </form> hi i have following code Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <!--<meta http-equiv="refresh" content="51;url=quiz2action.php" />--> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Untitled Document</title> </head> <body> <div id = "time"></div> <script type = "text/javascript"> } function display(secs) { if (secs <= 0) { alert("Your time is up!"); return; } secs--; document.getElementById("time").innerHTML = "You have " + Math.floor(secs/60) + ":" + (secs % 60 < 10 ? "0" : "" ) + (secs % 60) + " left"; setTimeout("display("+secs+")",1000); } display(51); // 300 seconds = 5 minutes </script> <p> <form name="form1" method="post" action="quiz2action.php"> <?php $db = mysql_connect("localhost"); mysql_select_db("videoshop", $db); //$queryquestions = "SELECT * FROM quiz ORDER BY RAND()" or die(); $queryquestions = "SELECT * FROM quiz" or die(); $resultquestions = mysql_query($queryquestions) or die(); while($rowquestions = mysql_fetch_array($resultquestions)) { $questionid = $rowquestions['id']; $question = $rowquestions['question']; $answerone = $rowquestions['option1']; $answertwo = $rowquestions['option2']; $answerthree = $rowquestions['option3']; $answerfour = $rowquestions['option4']; echo " <b>Question $questionid: $question</b><br> <input type=\"radio\" name=\"question[$questionid]\" value=\"1\"> $answerone <br> <input type=\"radio\" name=\"question[$questionid]\" value=\"2\"> $answertwo <br> <input type=\"radio\" name=\"question[$questionid]\" value=\"3\"> $answerthree <br> <input type=\"radio\" name=\"question[$questionid]\" value=\"4\"> $answerfour <br>"; echo "<br><br>"; } ?> </p> <label> <input type="submit" name="Submit" id="button" value="Submit"> </label> </form> <p> </p> </body> </html> above is the code of quiz which is created in php. that quiz is fine. the problem in in js script above the php script. what i want is when the time of 5 mins is completed then i want to disable all those radio buttons except submit button. how can this be done? hi i was wondering if there was anyway i can check a check box with the help of javascript and have it add text from a database record to a text box without submitting the page with the help from php? i have the php coding done to get the info and edit it but cant have no idea how to do the javascript code thanks. PHP code: PHP 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="user_pm"> <?php $sql="SELECT * FROM list WHERE username='usernamehere'"; $result=mysql_query($sql); $count=mysql_num_rows($result); ?> <table width="496" border="0" cellspacing="1" cellpadding="0"> <tr> <td><form name="form1" method="post" action=""> <table width="495" border="0" cellpadding="3" cellspacing="1" bgcolor="#000000"> <tr> <td align="left" bgcolor="#3576B4" width="26"><font color="#FFFFFF" size="2"><strong></strong></td> <td align="left" bgcolor="#3576B4" width="95"><font color="#FFFFFF" size="2"><strong>From:</strong></font></td> <td align="left" bgcolor="#3576B4" width="52"><font color="#FFFFFF" size="2"><strong>To:</strong></font></td> <td align="left" bgcolor="#3576B4" width="161"><font color="#FFFFFF" size="2"><strong>Message:</strong></font></td> </tr> <?php while($rows=mysql_fetch_array($result)){ ?> <tr> <td align="center" bgcolor="#f8f8f8" width="26"> <input name="checkbox[]" type="checkbox" id="checkbox[]" value="<?php echo $rows['id']; ?>" style="float: left"></td> <td bgcolor="#f8f8f8" width="95"><font size="2"><?php echo $rows['from']; ?></font></td> <td bgcolor="#f8f8f8" width="52"><font size="2"><?php echo $rows['to']; ?></font></td> <td bgcolor="#f8f8f8" width="161"><font size="2"><?php echo $rows['message']; ?></font></td> </tr> <?php } ?> <tr> <td colspan="6" align="center" bgcolor="#f8f8f8"> <input name="edit" type="submit" id="edit" value="Edit" style="float: left"></td> </tr> <?php $message = stripslashes($post['message']); $message = $_POST['message']; $checkbox = $_POST['checkbox']; $edit = $_POST['edit']; if($edit){ for($i=0;$i<$count;$i++){ $edit_id = $checkbox[$i]; mysql_query("UPDATE list SET message='$message' WHERE id='$edit_id' And username='usernamehere'"); } if($result){ echo "<meta http-equiv=\"refresh\" content=\"0;url=index.php\">\n"; } } mysql_close(); ?> </table> </form> </td> </tr> </table> </div> </body> </html> |