Page 1 of 1
Javascript
Posted: Wed Jul 26, 2006 4:45 am
by leewad
Hi
I`m trying to create a dropdown which if the value "for sale" is selected a text box appears to ask for the asking price, if any other value is selected the text box stays hidden. Can anyone help with this?
Many thanks
Lee
Posted: Wed Jul 26, 2006 7:53 am
by CoderGoblin
This cannot be done in PHP. You will need to use Javascript with the textbox for user entry initially hidden.
Posted: Wed Jul 26, 2006 8:43 am
by leewad
Yes I know it has to be done in javascript hence the title. I need help with the javascript as i dont know how to do it.
Posted: Wed Jul 26, 2006 8:45 am
by feyd
What help and how much help, specifically, for this javascript? The dirty basics: use the onchange event of the <select>.
Posted: Wed Jul 26, 2006 9:51 am
by leewad
All the help I can get, I dont know javascript at all, php yes but not Javascript and would like help how to create it.
Posted: Wed Jul 26, 2006 10:38 am
by asgerhallas
feyd | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Something like this:
[syntax="javascript"]function ShowHide()
{
obj=document.getElementById('IDOfElementToShowOrHide');
if (obj.style.display=='none') obj.style.display='show';
else obj.style.display='hide';
}
on the select tag try something like this:
onchange="ShowHide()"
... untested...
feyd | Please use[/syntax]Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Posted: Wed Jul 26, 2006 12:12 pm
by daedalus__