How do you make a value show up in a text box, when a radio button is clicked, in javascript?
-
<?xml version= "1.0" encoding= "UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtm… <html xmlns= "http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <script type="text/javascript"> function validateForm() { if ( document.gymForm.MembershipOption[0].che… == true ) { alert("Wohhoo..You are a new Member..A $30 fees would be added as a Joining fee charge") return; } } </script> </head> <body> <form name="gymForm" action="[email protected]" method="post" onsubmit="return validateForm()"> <div style =" font-size:20pt; font-weight:bold; font-family:times new roman;"> MEMBERSHIP FORM </div> <span><input type="radio" name="MembershipOption" value="30" onclick="validateForm()" /> New Member (Fill in Section 1, 2 and 3) <input type="radio" name="MembershipOption" value="New" /> Renewing Member (Fill in Section 1 and 3)</span> <form name="gymForm" action="http://tl28serv.uws.edu.au/twain… method="post" onsubmit="return validateForm()"> <p> Joining Fee: $ <input type="text" name="JoiningFee" value="0" style="width:2cm; color:black; background-color:white" /> <p class="submit"> <input type="Submit" value="Submit" onClick=" return ValidateForm(this.form)" style="height:25px; border-style:solid; border-size:1px; border-color:blue; width:100px; font-weight:bold; color:blue; background-color:#D1D2D4" /> </p> </form> </body> </html>
-
Answer:
An example. http://pastebin.com/aH7Qf6Nj Hope it helps. - Dominic
Dominic at Yahoo! Answers Visit the source
Other answers
$('input[type="radio"]').click(function(… { var this_index_limit = parseInt($(this).val()); for(var i = 0; i < this_index_limit; i++) { if(!$('#text_box_' + i).length) { $('<input id="text_box_' + i + '" type="text"/>').appendTo($(this).parent(… } else if($('#text_box_' + i).is(':hidden')) { $('#text_box_' + i).show(); } } $('input[type="text"]').each(function() { var split_id = $(this).attr('id').split('_'); if(!split_id.length) return; //from each function, not the outer click function. var index = parseInt(split_id[2]); if(index >= this_index_limit) { $(this).hide(); } }); });
Jenny
Related Q & A:
- How do i make a my yahoo but not a home page?Best solution by Yahoo! Answers
- Does anybody have a realy cool design for a speaker box for a tj with no back seat?Best solution by Yahoo! Answers
- How do I make a text box on Myspace?Best solution by Yahoo! Answers
- How do I make a CV to apply for a job?Best solution by wikihow.com
- How do you make a web show?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.