Click to See Complete Forum and Search --> : Display Textbox on Selected Choice?
localhost
03-26-2003, 02:48 AM
Hi all,
I'm wondering if there's anyway to display a textbox with different purposes when a user selects a item in the dropdown list (pulldown menu)?
For Example,
In a dropdown list, there's Choice 1, Choice 2 and so on. The user is only allowed to select one. Hence, if the user select 'Choice 1', it'll make use of the onChange keyword to execute a code that will display a specific textbox (EG: Enter Information: ) below the option.
Thanks in advance :)
khalidali63
03-26-2003, 07:22 AM
Try the link below
http://68.145.35.86/skills/javascripts/ShowHideFormElement.html
Its the same idea for showing and hiding elements.
in this example its the check box that appears or disappears you can use it for any element.
Cheers
Khalid
localhost
03-26-2003, 07:46 AM
Ah, ok. I'll check it out and give u feedback.
Thanks :)
localhost
03-27-2003, 05:00 AM
Hi all,
I managed to have this bit of code.
Here's how it works:
divid is the DIV tag entered in under 'ID' in the <tr> HTML portion which the textbox should hide and display. For example, in <tr>, there's <tr ID="textlayer">. Hence, when i select an item from the dropdown list, if it matches the value in the dropdown list (as assigned), it'll display the textbox. If other option is selected, it'll hide the textbox.
function showHide(divid)
{
divtag = eval(divid)
if (divtag.style.display == "none" && document.shear_clear.clearance.value == "dieclr")
{
divtag.style.display = "block";
}
else
{
if (divtag.style.display == "block")
{
divtag.style.display = "none";
}
}
}
So, to clear the textbox shown, i need to insert this code at the end of my HTML
textlayer.style.display = "none";
I called up the script using: onChange="javascript:showHide('textlayer')"
So, I would like to know how can I modify the code so that if item 'A' is selected, it shows the textbox for item 'A' but if item 'B' is selected, it shows the textbox for item 'B' only. But if none is selected, it'll not show any textbox.