| | |
chechbox validations
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
hello friends ..
i want to do one task. i want some one elp. i am new to php. when ever i check the checkbox amount will add in 'total' textbox.
i am displaying table below.
here no.of checkboxs. when ever i check one checkbox that amt willadd to total amount.
plz help me.
i want to do one task. i want some one elp. i am new to php. when ever i check the checkbox amount will add in 'total' textbox.
i am displaying table below.
PHP Syntax (Toggle Plain Text)
<form name="form" action="" method="post" > <table align="center"> <tr> <td> </td> </tr> <tr> <td> </td> </tr> <tr> <td> </td> </tr> <tr> <td> Make my add featured $19.95 (your ad seen before free listings) </td> <td> </td> <td><input type="checkbox" name="chk1" onclick="check1()"/></td></tr> <tr> <td> </td> <td> </td> </tr> <tr> <td> Make my ad bold $4.95 </td> <td> </td> <td><input type="checkbox" name="chk2" /></td></tr> <tr> <td> </td> <td> </td> </tr> <tr> <td> Make my ad highlighted $4.95 </td> <td> </td> <td><input type="checkbox" name="chk3" /></td></tr> <tr> <td> </td> <td> </td> </tr> <tr> <td> Add Email $9.95 </td> <td><input type="text" name="email" /></td> <td><input type="checkbox" name="chk4" /></td></tr> <tr> <td> </td> <td> </td> </tr> <tr> <td> Add link to my website $9.95 </td> <td><input type="text" name="link" /></td> <td><input type="checkbox" name="chk5" /></td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td>Add 10 key words $9.95 <input type="checkbox" name="chk6" /> or</td> <td>Add 20 keywords $19.95 <input type="checkbox" name="chk7" /></td> </tr> <tr> <td><textarea name="text1" rows="6" cols="50"></textarea></td> <td> </td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td> Add larger description (up to 4,000 charters) $29.95 </td> <td> </td> <td><input type="checkbox" name="chk8" /></td></tr> <tr> <td> </td> <td> </td> </tr> <tr> <td><textarea name="text1" rows="6" cols="50"></textarea></td> <td> </td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td>Add 10 key words $9.95 <input type="checkbox" name="chk6" /> or</td> <td>Add 20 keywords $19.95 <input type="checkbox" name="chk7" /></td> </tr> <tr> <td><textarea name="text1" rows="6" cols="50"></textarea></td> <td> </td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td align="right">total <input name="total" type="text" /></td> </tr> </table> </form>
here no.of checkboxs. when ever i check one checkbox that amt willadd to total amount.
plz help me.
0
#2 24 Days Ago
Found this link, and made it into this:
http://expressionengine.com/forums/viewthread/128806/
http://expressionengine.com/forums/viewthread/128806/
PHP Syntax (Toggle Plain Text)
<html> <head> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function() { var total = 0; function calcTotal() { $("input:checked").each(function() { var value = $(this).attr("value"); total += parseFloat(value); }); } calcTotal(); $("input:checkbox, input:radio").click(function() { total = 0; calcTotal(); $("input#total").val(total); }); }); </script> </head> <body> <form name="form" action="" method="post" > <table align="center"> <tr> <td>Make my add featured $19.95 (your ad seen before free listings)</td> <td> </td> <td><input type="checkbox" value="19.95" /></td> </tr> <tr> <td>Make my ad bold $4.95</td> <td> </td> <td><input type="checkbox" value="4.95" /></td> </tr> <tr> <td>Make my ad highlighted $4.95</td> <td> </td> <td><input type="checkbox" value="4.95" /></td> </tr> <tr> <td>Add Email $9.95</td> <td><input type="text" name="email" /></td> <td><input type="checkbox" value="9.95" /></td> </tr> <tr> <td>Add link to my website $9.95</td> <td><input type="text" name="link" /></td> <td><input type="checkbox" value="9.95" /></td> </tr> <tr> <td>Add 10 key words $9.95 <input type="checkbox" value="9.95" /></td> <td>or</td> <td>Add 20 keywords $19.95 <input type="checkbox" value="19.95" /></td> </tr> <tr> <td><textarea name="text1" rows="6" cols="50"></textarea></td> <td> </td> <td> </td> </tr> <tr> <td>Add larger description (up to 4,000 charters) $29.95</td> <td> </td> <td><input type="checkbox" value="29.95" /></td> </tr> <tr> <td><textarea name="text1" rows="6" cols="50"></textarea></td> <td> </td> <td> </td> </tr> <tr> <td>Add 10 key words $9.95 <input type="checkbox" value="9.95" /></td> <td>or</td> <td>Add 20 keywords $19.95 <input type="checkbox" value="19.95" /></td> </tr> <tr> <td><textarea name="text1" rows="6" cols="50"></textarea></td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td align="right">total <input id="total" type="text" /></td> </tr> </table> </form> </body> </html>
Last edited by pritaeas; 24 Days Ago at 4:35 am. Reason: removed indent
"If it is NOT source, it is NOT software."
-- NASA
-- NASA
0
#7 24 Days Ago
you are looking for a radio button not a check box. Only one radio button gets selected from a defined group.
Just define each radio button in a specific group under the same "name" attribute. eg: option1 name="group1" option2 name="group1" option 3 name="group2"
above example lets you choose only 1 out of option 1 and 2 but lets u select option 3 simultaneously
Just define each radio button in a specific group under the same "name" attribute. eg: option1 name="group1" option2 name="group1" option 3 name="group2"
above example lets you choose only 1 out of option 1 and 2 but lets u select option 3 simultaneously
•
•
•
•
in this we can not group check boxes. so how can we select onlyone from two check boxes in the case of 'OR' case. for example checkbox1 (or)checkbox2. in this case we have to select only one checkbox. if one checkbox checked automatically other will be in uncheck.
Last edited by venkat0904; 24 Days Ago at 5:04 am.
0
#8 24 Days Ago
•
•
•
•
you are looking for a radio button not a check box. Only one radio button gets selected from a defined group.
Just define each radio button in a specific group under the same "name" attribute. eg: option1 name="group1" option2 name="group1" option 3 name="group2"
above example lets you choose only 1 out of option 1 and 2 but lets u select option 3 simultaneously
0
#9 24 Days Ago
i think u didnt get me... checkboxes are meant for multiple selection... 1 checkbox is not supposed to be influenced by selection of other but radio buttons are meant to do so... like wen u need to select a gender u use a radio button coz u dont want both male n female to b selected..
0
#10 24 Days Ago
•
•
•
•
i think u didnt get me... checkboxes are meant for multiple selection... 1 checkbox is not supposed to be influenced by selection of other but radio buttons are meant to do so... like wen u need to select a gender u use a radio button coz u dont want both male n female to b selected..
![]() |
Similar Threads
- Help with Implementing email form validations please (PHP)
- validations are not working on div (JavaScript / DHTML / AJAX)
- Jsp validations (JSP)
- Validations? (JavaScript / DHTML / AJAX)
- defining objects, variables and checking validations for java (Java)
- how to implement validations for chinese characters (C#)
- jsp-struts using validations (JSP)
Other Threads in the PHP Forum
- Previous Thread: Tiles Matching Game, Sessions 1D array // random_shuffle()
- Next Thread: refresh part of the page
| Thread Tools | Search this Thread |
advanced apache api array basics beginner binary broken cakephp check checkbox class cms code codingproblem combobox cookies cron curl database date datepart display dynamic echo email error file files folder form forms function functions google head href htaccess html image include includingmysecondfileinthechain insert ip javascript job joomla js limit link login mail menu mlm mobile multiple mysql oop outofmemmory paging parse password paypal pdf php problem procedure query radio ram random recursion remote script search server sessions smarty sms source space sql stored syntax system table traffic tutorial unicode up-to-date update upload url validator variable video web webapplications websitecontactform youtube





