Page 1 of 1

Textfield visibility

Posted: Thu May 01, 2008 6:46 am
by KSL
Hi i am new to PHP so this may (hopefully) just be a simple problem.

I am creating a contact form on my website using some freeware code i have found. The page works perfectly but i wanted to do a little tweeking.

In my form i have the question with a list/menu box "where did you find us", one of the selections is google. When this is selected by the user i want a previously hidden text field to appear asking which search term they used to find our site.

Can anybody help out with this code?

Cheers

KSL

Re: Textfield visibility

Posted: Thu May 01, 2008 7:46 am
by aceconcepts
You could do this with PHP by it would mean the user would have to click a submit button - not very good.

Your best bet would be to use Javascript.

Re: Textfield visibility

Posted: Thu May 01, 2008 11:18 am
by pickle
Ya, you should use Javascript for this.

Something like (not tested):

Code: Select all

 
function showField()
{
  if(document.getElementById('pulldown').value == 'google');
    document.getElementById('myHiddenField').style.display = 'inline';
  else
    document.getElementById('myHiddenField').style.display = 'none';
}
.....
 
<select id = "pulldown" onchange = "showField();" >
...
</select>
<input type = "text" id = "myHiddenField" style = "display:none;" />
 
 
If the javascript solution is what you're looking for, I can move this thread to the Client-Side forum if you want.

Re: Textfield visibility

Posted: Mon May 05, 2008 5:13 am
by KSL
Thank you all sorted now.