Radio Button & Text Field Comment

K

Kathy

Is there a way to have a text field associated with a radio button so that if
someone selects that radio button they are forced to enter data in the text
field?
 
M

MD Websunlimited

Hi Kathy,

Yes there is. BTW you related to Mark?

<head>

<meta name="GENERATOR" content="Microsoft FrontPage 6.0">

<meta name="ProgId" content="FrontPage.Editor.Document">

<title>New Page 3</title>

<script type="text/javascript" language="javascript">

function checkAnswer(theForm) {

debugger;

if (theForm.yesno[1].checked) {

if (theForm.Response.value.length > 0 ) {

return true;

} else {

alert("Please enter a reason.");

return false;

}

}

return true;

}

</script>

</head>

<body>

<form name="form1">

<input type="radio" checked name="yesno" > Yes

<input type="radio" name="yesno" onclick="this.form.Response.disabled=false; this.form.Response.focus(); alert('Please enter the
reason.'); " > No

<textarea name="Response" disabled >

</textarea>

<input type="submit" onclick="checkAnswer(this.form);" >

</form>

</body>

</html>
 
M

MD Websunlimited

<select onchange="checkTotal(this.form)" >
<option vaue="1">1</option>
....
</select>

<script language="javascript" >

function checkTotal(theForm) {
var total = theForm.select1.options[theForm.select1.selectedIndex].value;
total += theForm.select2.options[theForm.select2.selectedIndex].value;
total += theForm.select3.options[theForm.select3.selectedIndex].value;
total += theForm.select4.options[theForm.select4.selectedIndex].value;
total > 14 ? alert("The total number of items selected may not exceed 14"); : theForm.select1.focus();
}

BTW you related to Mike?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top