Making One Field Required Based on Previous

R

RoadKill

How do I make one field required in Frontpage by the answer of a previous
field?

In my example below, if QuestionOne was two or less, how can I make the
Q1Comments required?

Thank you

<td valign="top" width="28%">
<p align="center">
<input type="radio" name="QuestionOne" value="5"><span
lang="en-us">5</span><input type="radio" name="QuestionOne" value="4"><span
lang="en-us">4</span><input type="radio" name="QuestionOne" value="3"><span
lang="en-us">3</span><input type="radio" name="QuestionOne" value="2"><span
lang="en-us">2</span><input type="radio" name="QuestionOne" value="1"><span
lang="en-us">1</span>
</td>

<td valign="top" width="27%" align="center">
<textarea rows="2" name="Q1Comments" cols="20"></textarea></td>
 
T

Trevor Lawrence

RoadKill said:
How do I make one field required in Frontpage by the answer of a previous
field?

In my example below, if QuestionOne was two or less, how can I make the
Q1Comments required?

Thank you

<td valign="top" width="28%">
<p align="center">
<input type="radio" name="QuestionOne" value="5"><span
lang="en-us">5</span><input type="radio" name="QuestionOne"
value="4"><span
lang="en-us">4</span><input type="radio" name="QuestionOne"
value="3"><span
lang="en-us">3</span><input type="radio" name="QuestionOne"
value="2"><span
lang="en-us">2</span><input type="radio" name="QuestionOne"
value="1"><span
lang="en-us">1</span>
</td>

<td valign="top" width="27%" align="center">
<textarea rows="2" name="Q1Comments" cols="20"></textarea></td>

My first reaction was that you have many elements with the same name
(name="QuestionOne")
Second, I think id= is preferable to name=

Anyway, you would need JavaScript to show/hide the <textarea>

My thoughts are (not tested)
HTML
<form id="myForm" action="">
.....
<td valign="top" width="28%">
<input type="radio" id="QuestionOne" value="5">
......
</td>
......
<td valign="top" width="27%" align="center"></td>
<span id="Q1C" ></span>.
</td>
.....
</form>


and the JS
if ( document.forms['myForm'].elements['QuestionOne'].value == "5") {
document.getElementById('Q1C').innerHTML=
'<textarea id="Q1Comments" rows="2" cols="20"></textarea>' ;
}

or using dot notation
if (document.forms.myForm.elements.QuestionOne.value == "5") {
document.getElementById('Q1C').innerHTML=
'<textarea id="Q1Comments" rows="2" cols="20"></textarea>' ;
}

JS experts can say which of these two meets the standards
 

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