Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
120
rated 0 times [  125] [ 5]  / answers: 1 / hits: 68222  / 13 Years ago, tue, november 29, 2011, 12:00:00

I'm borrowing/adapting this simple html/javascript form set up to put some data in the database. The original code uses text fields in the form, but I'm using radio buttons. The first three steps below are the original, and my question comes after...namely, do I give the radio buttons the same id...Hope this is clear...



Step 1. User enters value into form with id nick



<tr>  
<td><label>User</label></td>
<td><input class=text user id=nick type=text MAXLENGTH=25 /></td>
</tr>


Step 2. Value associated with id nick assigned to variable using id



var inputUser = $(#nick);  


Step 3. getting the value from the variable for insertion into database...



if(inputUser.attr(value)


but if it's two radio buttons rather than one text field....



<td><label>Interview</label></td>  
<td><input type=radio name=interview id=nick value=pass />Pass</td>
<td><input type=radio name=interview id=nick value=fail /> Fail</td>


Do I give the radio buttons the same id so that it's still like this when I assign the value to the variable...



var inputUser = $(#nick); 


so that whichever button is checked will be assigned found in the id nick?


More From » html

 Answers
7

No, an Id attribute should always be unique. If you're using jQuery (looks like you are), you can select it with $('input[name=interview]');.


[#88861] Sunday, November 27, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
christianu

Total Points: 481
Total Questions: 124
Total Answers: 99

Location: Trinidad and Tobago
Member since Thu, Dec 1, 2022
2 Years ago
;