Javascrip question: hi how do i make a text field value change when a radio button is clicked?
-
Like a situation where a user wants to register for a gym, and the gym has a membership type, which includes gym, zumba lesson, and taekwando..each membership type has a value(i.e amount)..and when selected, a value should appear on the text filled called Program fee.There is also an option that says membership term..with options 1 month, 3 months, 6 months, and 12 months..all of this should be calculated if a user ticks a particular filled.. Lets say each membership cost $20 per month, and a user selects 2 membership options and selects 3 months, can you help me create a code to generate an output in the text filled (Program fee)..i.e gym = $20 per month taekwando = $20 per month user selects both options and selects 3 months membership term Program fee should produce: 20 + 20 = 40 * 3 months = $120 Please i need immediate help...Thanks in advance here is my code i tried out, can you edit and fix it up please Thanks in Advance <?xml version= "1.0" encoding= "UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml… <html xmlns= "http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <script type="text/javascript"> var total = 0; function ShowPFee(obj) { var price; var i; if (obj.checked) //user must have selected the box total = total + eval(obj.value); else //user must have DEselected the box total = total - eval(obj.value); document.getElementById("gymForm").Pro… = total; return; } </script> </head> <body> <form name="gymForm" id="gymForm"> <p><b> Membership Type:</b> <input type="checkbox" name="MembershipType1" value="20" onclick="ShowPFee(this)" class="check-1" /> Gym <input type="checkbox" name="MembershipType2" value="20" onclick="ShowPFee(this)" class="check-2" /> Group Fitness <input type="checkbox" name="MembershipType3" value="20" onclick="ShowPFee(this)" class="check-1" /> Boxing <input type="checkbox" name="MembershipType4" value="20" onclick="ShowPFee(this)" class="check-2" /> Taekwondo </p> <p><b> Membership Term: </b> <input type="radio" name="MembershipTerm" class="check-1" onclick="ShowPFee1(this)" /> 1 Month<input type="radio" name="MembershipTerm" class="check-2" onclick="ShowPFee1(this)" /> 6 Months <input type="radio" name="MembershipTerm" class="check-1" onclick="ShowPFee1(this)"/> 3 Months <input type="radio" name="MembershipTerm" onclick="ShowPFee1(this)" /> 12 Months </p> <p> Program Fee $ <input type="text" name="ProgramFee" value="0" style="width:2cm; color:black; background-color:white" /> </p> </form> </body> </html>
-
Answer:
I made this for you: http://jsfiddle.net/eBC6C/1/ it wasn't that hard. you should've been able to figure it out yourself.
Yahoo! Answers Visit the source
Related Q & A:
- How do i make a signature for when i send an email?Best solution by Yahoo! Answers
- How do I make a text box on Myspace?Best solution by Yahoo! Answers
- How do I make a henna tattoo darker when the paste is already off?Best solution by leezees.com
- How do I send a text from my computer to a landline?Best solution by Blurtit.com
- How can I get a text alert when I get an email?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.