HighDots Forums  

Form question

Macromedia Dreamweaver Macromedia Dreamweaver Discussions (macromedia.dreamweaver)


Discuss Form question in the Macromedia Dreamweaver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Necroscope webforumsuser@macromedia.com
 
Posts: n/a

Default Form question - 11-24-2003 , 09:59 AM






I have created a fairly simple form in Dreamweaver 4.

One question uses a group of four radio buttons and one of the options is "Other". A text field has been added next to the "Other" option so that users can provide additional information.

What I am trying to do is get the text box to appear when the "Other" radio button is selected.

At the present, the text box is on screen permanently but I would like to hide this and have it visible only if the "Other" option is selected...

Can anyone help?

Thanks



Reply With Quote
  #2  
Old   
Gary White
 
Posts: n/a

Default Re: Form question - 11-24-2003 , 11:56 AM






On Mon, 24 Nov 2003 14:59:23 +0000 (UTC), "Necroscope"
webforumsuser (AT) macromedia (DOT) com wrote:

Quote:
One question uses a group of four radio buttons and one of the
options is "Other". A text field has been added next to the "Other"
option so that users can provide additional information.

What I am trying to do is get the text box to appear when the "Other"
radio button is selected.
Place this in the <head> of the document:

<script type="text/javascript">
function setVis(){

document.forms[0].txtOther.style.visibility=document.forms[0].rdoOther.checked?'visible':'hidden';
}
</script>

This assumes that the ID for the radio button for "Other" is
"rdoOther". Change that to whatever you actually put in the ID
attribute. Give all the radio buttons the same NAME, but give each a
unique ID.

Then, for each of the radio buttons, add onClick="setVis()" for
example:

<input name="radiobutton" type="radio" value="button2" id="button2"
onClick="setVis()">



Gary


Reply With Quote
  #3  
Old   
mick_white
 
Posts: n/a

Default Re: Form question - 11-24-2003 , 12:04 PM





"Necroscope" webforumsuser (AT) macromedia (DOT) com wrote:

Quote:
I have created a fairly simple form in Dreamweaver 4.

One question uses a group of four radio buttons and one of the options is "Other". A text field has been added next to the "Other" option so that users can provide additional information.

What I am trying to do is get the text box to appear when the "Other" radio button is selected.

At the present, the text box is on screen permanently but I would like to hide this and have it visible only if the "Other" option is selected...

Can anyone help?

Thanks







Reply With Quote
  #4  
Old   
mick_white
 
Posts: n/a

Default Re: Form question - 11-24-2003 , 12:04 PM



Do you need to support NN4?
Mick

"Necroscope" webforumsuser (AT) macromedia (DOT) com wrote:

Quote:
I have created a fairly simple form in Dreamweaver 4.

One question uses a group of four radio buttons and one of the options is "Other". A text field has been added next to the "Other" option so that users can provide additional information.

What I am trying to do is get the text box to appear when the "Other" radio button is selected.

At the present, the text box is on screen permanently but I would like to hide this and have it visible only if the "Other" option is selected...

Can anyone help?

Thanks







Reply With Quote
  #5  
Old   
mick_white
 
Posts: n/a

Default Re: Form question - 11-24-2003 , 12:27 PM



I'm not sure that will work, Gary
function setVis(element,radiogroup){
for(r=0;r<radiogroup.length;r++){
if(radiogroup[r].value=="other"){
element.style.display=radiogroup[r].checked?'block':'none';
return;
}
}
}
onclick="setVis(this,textfieldName)"
Mick

Gary White wrote:

Quote:
On Mon, 24 Nov 2003 14:59:23 +0000 (UTC), "Necroscope"
webforumsuser (AT) macromedia (DOT) com wrote:



One question uses a group of four radio buttons and one of the
options is "Other". A text field has been added next to the "Other"
option so that users can provide additional information.

What I am trying to do is get the text box to appear when the "Other"
radio button is selected.



Place this in the <head> of the document:

script type="text/javascript"
function setVis(){

document.forms[0].txtOther.style.visibility=document.forms[0].rdoOther.checked?'visible':'hidden';
}
/script

This assumes that the ID for the radio button for "Other" is
"rdoOther". Change that to whatever you actually put in the ID
attribute. Give all the radio buttons the same NAME, but give each a
unique ID.

Then, for each of the radio buttons, add onClick="setVis()" for
example:

input name="radiobutton" type="radio" value="button2" id="button2"
onClick="setVis()"



Gary





Reply With Quote
  #6  
Old   
Gary White
 
Posts: n/a

Default Re: Form question - 11-24-2003 , 01:17 PM



On Mon, 24 Nov 2003 12:27:34 -0500, mick_white <mick (AT) gerrytimlin (DOT) com>
wrote:

Quote:
I'm not sure that will work, Gary
It works in IE and Gecko, but <sigh> you're right. It fails in NN4.

Quote:
function setVis(element,radiogroup){
for(r=0;r<radiogroup.length;r++){
if(radiogroup[r].value=="other"){
element.style.display=radiogroup[r].checked?'block':'none';
return;
}
}
}
onclick="setVis(this,textfieldName)"

Your function appears to be expecting the radio group as the second
parameter, but your example seems to be passing the name of the text
input. Will that work?


Gary


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.