Radio button only renders radio button not text
Asked Answered
C

4

6
 <input type="radio" id="rdoHalfDay" name="rdoHalfDay" value="Half Day" />

Above code only render radio button not text
I am using Firefox 9.0.1 also same problem in IE


<%=Html.RadioButton("rdoTest","Cricket") %>;

If I am using above code in Asp.net MVC 3 then below HTML generates that not shows text

<input id="rdot" type="radio" value="Cricket" name="rdot">
Catharine answered 14/2, 2012 at 6:20 Comment(2)
you are using radio button not textBraided
I need radio button with text(value) i.e is in above example "Half Day"Catharine
L
10

Works as defined. To specify radio button text, include it as textual content, preferably using label markup (though this is not formally required):

<input type="radio" id="rdoHalfDay" name="rdoHalfDay" value="Half Day" />
<label for="rdoHalfDay">Half day</label>

Note that the value of the value attribute of a input type="radio" only specifies the data to appear in the form data submitted (and could be anything that you can conveniently handle in your software). It is not supposed to appear and will not normally appear as visible content (except if the form handling software has been written to “echo” it to the user).

Loutish answered 14/2, 2012 at 6:28 Comment(0)
C
5

The text inside the value attribute is only the value that gets sent to the server if that radio button happens to be checked at the time of submission. It doesn't actually get displayed on the page. This is useful in case you use compressed versions of the corresponding text as the values in your server, which would represent the full text, like so:

<label><input type="radio" name="rdo" value="HalfDay" /> Half Day</label>
Cruel answered 14/2, 2012 at 6:27 Comment(0)
S
1

Radio buttons don't work like that. The text is specified outside the tag. The value is what is passed back to the server when the form is submitted. See the following example:

<form name="myform" action="http://www.mydomain.com/myformhandler.cgi" method="POST">
  <div align="center"><br>
    <input type="radio" name="group1" value="Milk"> Milk<br>
    <input type="radio" name="group1" value="Butter" checked> Butter<br>
    <input type="radio" name="group1" value="Cheese"> Cheese
    <hr>
    <input type="radio" name="group2" value="Water"> Water<br>
    <input type="radio" name="group2" value="Beer"> Beer<br>
    <input type="radio" name="group2" value="Wine" checked> Wine<br>
  </div>
</form>

See: http://www.echoecho.com/htmlforms10.htm

Singley answered 14/2, 2012 at 6:24 Comment(0)
B
0
<label for="lDIV1">
<input id="lDIV1" type="radio" name='rbtab' value='DIV1' onclick="javascript:custom()" 
/>Create
Email:</label>
<label for="lDIV2">
<input id="lDIV2" type="radio" name='rbtab' checked="checked"  value='DIV2' 
onclick="javascript:defaul()" />Default
Email:</label>
<div id='Content' style="display: block">

For Radio button

<form>
<input type="radio" name="sex" value="male" /> Male<br />
<input type="radio" name="sex" value="female" /> Female
</form>
Braided answered 14/2, 2012 at 6:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.