Click to See Complete Forum and Search --> : Enable textarea upon radio button selection - HELP!


r0bertstevenfis
10-17-2003, 07:00 AM
Hi all,
I have been trying to get a script working which will allow textareas to be either DISABLED or not depending on whether they have clicked the radio button associated with the textarea.

This is for a survey type form, and I have many questions on the survey... most all radio button answers. Then I allow an additional comments field where they can give text input... but ONLY if they have first answered the question using the radio button.

The entire form is dynamically created looping through database fields and making the form on the fly.

My code so far looks like this:

<script language=javascript>

function EnableCommentsArea#GetEvaluationQuestions.ID#()
{
var RadioIndex;
for (RadioIndex = 0;
RadioIndex < document.EvaluationForm.IDPollAnswers#GetEvaluationQuestions.ID#.length;
RadioIndex++)

{
if (document.EvaluationForm.IDPollAnswers#GetEvaluationQuestions.ID#[RadioIndex].checked == true)
{
document.EvaluationForm.Comments#GetEvaluationQuestions.ID#.disabled==false;

}
else
{
document.EvaluationForm.Comments#GetEvaluationQuestions.ID#.disabled==true;


}
}

alert("you must make a selection before making comments");
}

</script>

then I have a radio button array, followed by the text area (looped and identified by the IDPollQuestions variable from the query):

<INPUT TYPE="radio"
NAME="IDPollAnswers#GetEvaluationQuestions.IDPollQuestions#"
VALUE="#GetEvaluationQuestions.AnswerID#">

<TEXTAREA COLS="80" ROWS="2" NAME="Comments#GetEvaluationQuestions.IDPollQuestions#" onKeyPress="EnableCommentsArea#GetEvaluationQuestions.ID#()"></TEXTAREA>

I am wasting far too much time on this, as I obviously am missing the boat on how to even think about this one.

Any assistance will be greatly appreciated!

Thanks

Charles
10-17-2003, 07:13 AM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Content-Script-Type" content="text/javascript">
<title>Example</title>

<style type="text/css">
<!--
label {display:block; margin:1em 0em}
textarea {display:block}
-->
</style>

<form action="">
<div>
<label><input type="checkbox" onclick="this.form.comments.onfocus = this.checked ? function () {} : function () {this.blur()}">Other</label>
<label>Comments<textarea name="comments" onfocus="this.blur()"></textarea></label>
</div>
</form>

crabplace
10-29-2003, 10:04 AM
I want to populate a drop down menu with an option when a visitor clicks a radio button.

Our visitors have to decide between steamed or live crabs by clicking a radio button. If they click steamed crabs they can then chose mild, medium, heavy or no seasoning from a drop down menu. Seasoning is not offered for live crabs, so when the live crab radio button is clicked, we want the drop down menu to freeze at "none."

Here is the URL for the page:

http://www.crabplace.com/shopping/hardcrabs2.asp

Thanks for your help!