Displaying text/input field depending on checkbox value 
Author Message
 Displaying text/input field depending on checkbox value

Hello...

I have a form & would like to display a "follow-up" question which is
phrased depending
on the result of a check box for the previous question. For example:

Question 1: Have you done anything differently as the result of the course?
Yes        [x]
No         []

Question 1a: What do you do now that you didn't do before?

(if the user then clicks on the "No" checkbox, then the question text gets
changed
to something different)

Can this be done?

I've had a look at various references & can't find anything specific...

Any help'd be appreciated.



Mon, 14 Apr 2003 22:20:14 GMT  
 Displaying text/input field depending on checkbox value
You will need to use the Style attribute to make the 1a question visible or
invisible and the innerHTML or innerText property to change the text.

A good DHTML Object Reference:
http://msdn.microsoft.com/workshop/author/dhtml/reference/objects.asp

Ryan
_________
This is madness!


Quote:

> Hello...

> I have a form & would like to display a "follow-up" question which is
> phrased depending
> on the result of a check box for the previous question. For example:

> Question 1: Have you done anything differently as the result of the
course?
> Yes        [x]
> No         []

> Question 1a: What do you do now that you didn't do before?

> (if the user then clicks on the "No" checkbox, then the question text gets
> changed
> to something different)

> Can this be done?

> I've had a look at various references & can't find anything specific...

> Any help'd be appreciated.



Tue, 15 Apr 2003 01:00:40 GMT  
 Displaying text/input field depending on checkbox value

In theory this should work with IE4+ and NS6. However, although NS does
change the innerHTML property of the label, the label disappears from the
screen in M18 when it changes.

  <script>
  arrQ1a = [ "What do you do now that you didn't do before?",
             "Why not?" ];

  function changeQ1a(choice) {
    var labQ1a = document.all ? document.all["labQ1a"] :            // IE
                                document.getElementById("labQ1a");  // NS
    labQ1a.innerHTML = "Question 1a: " + arrQ1a[choice];
  }
  </script>

  <form onsubmit="return false">
  Question 1: Have you done anything differently as the result of
  the course?<br>
  Yes: <input type="radio" name="q1" value="y"
              onclick="changeQ1a(0)"
       ><br>
  No : <input type="radio" name="q1" value="n"
              onclick="changeQ1a(1)"
       ><p>

  <label for="q1a" id="labQ1a">
  <script>document.write("Question 1a: " + arrQ1a[0]);</script>
  </label><br>
  <input type="text" size="75" name="q1a">
  </form>

As for NS4, you'd have to create forms with different questions on different
layers that you could hide/show depending on the radio button. You'd also
have to update matching fields in all the different forms whenever you
changed which one was being displayed. The number of different forms/layers
grows exponentially with every followup question you want to ask.

=-=-=
Steve
-=-=-


Quote:
> Hello...

> I have a form & would like to display a "follow-up" question which is
> phrased depending
> on the result of a check box for the previous question. For example:

> Question 1: Have you done anything differently as the result of the
course?
> Yes        [x]
> No         []

> Question 1a: What do you do now that you didn't do before?

> (if the user then clicks on the "No" checkbox, then the question text gets
> changed
> to something different)

> Can this be done?

> I've had a look at various references & can't find anything specific...

> Any help'd be appreciated.



Tue, 15 Apr 2003 05:07:51 GMT  
 Displaying text/input field depending on checkbox value

Quote:
> You will need to use the Style attribute to make the 1a question visible
or
> invisible and the innerHTML or innerText property to change the text.

> A good DHTML Object Reference:
> http://msdn.microsoft.com/workshop/author/dhtml/reference/objects.asp

An excellent resource - thanks very much.


Tue, 15 Apr 2003 16:31:08 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. need to feed a text field with values from other input

2. Form displays recordset depending of a value

3. Display value depend on parameters

4. Displaying Custom Text Field Values

5. Insert Text into field depending on dropdownlistbox

6. Value of Checkbox Set to two fields

7. form input field initial value truncate after space

8. Get form input field value before submit?

9. Checkbox value and text?

10. Combining values from a group of checkboxes into an unbound combobox field

11. Update text input fields in a child window - need help

12. simulate a rich text input field??

 

 
Powered by phpBB® Forum Software