Javascript

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
leewad
Forum Commoner
Posts: 91
Joined: Tue May 11, 2004 8:32 am

Javascript

Post 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
User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

Post by CoderGoblin »

This cannot be done in PHP. You will need to use Javascript with the textbox for user entry initially hidden.
leewad
Forum Commoner
Posts: 91
Joined: Tue May 11, 2004 8:32 am

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

What help and how much help, specifically, for this javascript? The dirty basics: use the onchange event of the <select>.
leewad
Forum Commoner
Posts: 91
Joined: Tue May 11, 2004 8:32 am

Post 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.
asgerhallas
Forum Commoner
Posts: 80
Joined: Tue Mar 14, 2006 11:11 am
Location: Århus, Denmark

Post by asgerhallas »

feyd | Please use

Code: Select all

,

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

,

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]
User avatar
daedalus__
DevNet Resident
Posts: 1925
Joined: Thu Feb 09, 2006 4:52 pm

Post by daedalus__ »

You need DevGuru
Post Reply