Form Question

They have: 3 posts

Joined: Mar 2004

Hi Everyone. I hope that someone can help me with a problem that I am having and I thank everyone who reads this.

Ok, here is my problem:

Just alittle background- I am using DreamweaverMX, and I am creating a table inside a form.

I am trying to create a feedback form. In one of the fields, I am using a checkbox yes/no, which is on the left side of the table. On the right side, I am asking the user if he/she would like email updates. What I want to do is this: If the user clicks the checkbox, a text area will appear where the user can input there email address. If they don't click the checkbox, the text area will not appear.

I hope that I have explained it well enough to understand.

Anyone have any ideas?

I have tried entering in Javascript, but can't seem to get it correct. I have also tried to do a onClick behavior, but can't get that right.

Any suggestions/code samples would be greatly appreciated.

Thanks in Advance for your help!

Don

Vincent Puglia's picture

They have: 634 posts

Joined: Dec 1999

Hi,

The following is one approach you can take:

<?php
&lt;script type='text/javascript'&gt;
function
doit()
{
  var
theTextBox = document.getElementById('eAdd')
 
theTextBox.style.display =  (theForm.theBox.checked) ? 'block' : 'none';
}
&
lt;/script&gt;
</
head>
<
body>
<
form name=\"theForm\">
<input type=\"checkbox\" onclick='doit()' name=\"theBox\">
<input id=\"theDiv\" style=\"display:none\" type=\"text\" name=\"eAdd\">

</form>
</body>
?>

Vinny

Where the world once stood
the blades of grass cut me still

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.