Click here to Skip to main content
15,918,404 members
Please Sign up or sign in to vote.
2.33/5 (2 votes)
See more:
I have multiple text boxes and radio buttons , when i click on one radio button to display text box then and enter details , then i click on next radio button . my previous text box hides . There is only on text box that i can see at a time .

code :
if($(this).val() === "yes")

$('input').click( function() {
if($(this).val()=== "no1")

                        <p>Temporary Extension of Area &nbsp; &nbsp; &nbsp; <label>Yes</label><input type="radio" name="type" value="yes" /> &nbsp; &nbsp; &nbsp;  <label>No</label><input type="radio" name="type"  value="no" /></p>
                        <p> <textarea id="textbox1" hidden="true" rows="7" cols="150" placeholder="Enter details & its reason with effect from extended area reasons for extension"></textarea>

<p>i. Possess Valid Storage License(Please Tick One)</p>
<table border="1" cellpadding="0" cellsapcing="0" border-style="solid" style="border-collapse: collapse" >
<th style="text-align: center; width: 50px;">J</th>
<th style="text-align: center; width: 50px;">XIII</th>
<th style="text-align: center; width: 50px;">XV</th>
<th style="text-align: center; width: 50px;">XVII</th>
<TH style="text-align: center; width: 50px;">NO LICENSES</TH>

<tr style="text-align: center; width: 50px;">
<td><input type="radio" name="licform" value="j"></td>
<td><input type="radio" name="licform" value="xiii"></td>
<td><input type="radio" name="licform" value="xv"></td>
<td><input type="radio" name="licform" value="xxvii"></td>
<td><input type="radio" name="licform" value="nolicense"></td></tr>
Sergey Alexandrovich Kryukov 31-Dec-15 2:39am    
Java? Where?
Sorry, but it's really hard to help someone who is clueless even about the language one uses.

1 solution

First of all, please see my comment to the question. If you have an illusion that you do anything related to Java, you should stop doing all you are doing and learn what is Java.

Now, you need to debug your code or trace execution, and do it all by yourself. You cannot ask such questions every time you runtime goes wrong. But let's address to pure logic first.

It's pretty obvious that the $("#texbox") element gets hidden only because you explicitly hide it in the line $('#textbox1').hide();. Probably, your "if" statement above this line always returns false. It's hard to imagine how you came to the idea that val() can become a string "yes". I have no clue. Is one of your labels or other similar elements has the value "yes"? :-)

This is how you can check up the state of a radio button with jQuery:
if (someRadioButton.prop("checked", true))

Isn't that simple?

Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900