Click to See Complete Forum and Search --> : Is it possible to assign a default value??


zincoxide
01-04-2005, 02:14 PM
I have a table of Questions that have radio buttons Yes/No.

I purposly didn't have one checked because I wanted to know if it was missed or not. However, when they submit the form it is completely left out if they don't select either Yes or No.

I was wondering if I can (as a default) have only 2 radio buttons (Yes/No) without one of them checked off. If the user misses the question the it will save the value as MISSED! so that I know that question was missed. If the user selects either Yes or No then that value is sent to me.

Here is what I have:


<tr>
<td colspan="3">
Has any insurer ever declined to issue, reinstate or renew, or has any insurer
rated, modified, postponed or cancelled, any life or health insurance on the Proposed Life
Insured:
</td>
<td width="30%" align="right" valign="bottom">
<input type="radio" name="RatedorDeclined" value="Yes">Yes&nbsp;&nbsp;
<input type="radio" name="RatedorDeclined" value="No">No&nbsp;&nbsp;&nbsp;&nbsp;
</td>
</tr>



can someone help here?

PeOfEo
01-04-2005, 03:48 PM
just put 'checked' within the tag of the radio button you want to be selected
http://www.w3.org/TR/html401/interact/forms.html#adef-checked

so
<input type="radio" name="RatedorDeclined" value="No" checked>No
will mean this is selected by default.

NogDog
01-04-2005, 03:59 PM
You could do something like this, perhaps, using CSS to hide a default, selected radio button:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang='en'>
<head>
<title>Form Test</title>
<style type="text/css">
input.hide {
display: none;
}
</style>
<body>
<form action="#" method="post">
<p>Select one:
<input type=radio name=choice value="yes">Yes
<input type=radio name=choice value="no">No
<input type=radio name=choice class=hide value="unknown" checked>
</p>
</form>
</body>
</html>

PeOfEo
01-04-2005, 04:03 PM
Originally posted by NogDog
You could do something like this, perhaps, using CSS to hide a default, selected radio button:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang='en'>
<head>
<title>Form Test</title>
<style type="text/css">
input.hide {
display: none;
}
</style>
<body>
<form action="#" method="post">
<p>Select one:
<input type=radio name=choice value="yes">Yes
<input type=radio name=choice value="no">No
<input type=radio name=choice class=hide value="unknown" checked>
</p>
</form>
</body>
</html>
the only downside to this is those without css would still see it... so I would give it a catchy value like "none of the above" or "neither", so when those people see it it looks like you ment to have that 3rd option there :D

NogDog
01-04-2005, 04:15 PM
Originally posted by PeOfEo
the only downside to this is those without css would still see it... so I would give it a catchy value like "none of the above" or "neither", so when those people see it it looks like you ment to have that 3rd option there :D
Good point. :cool:

zincoxide
01-04-2005, 08:36 PM
Thank you guys.