wood burning stoves 2.0*
The moose likes HTML, CSS and JavaScript and the fly likes textbox to listbox(simple) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "textbox to listbox(simple)" Watch "textbox to listbox(simple)" New topic
Author

textbox to listbox(simple)

Murasoli Maran
Ranch Hand

Joined: Jun 08, 2003
Posts: 193
Hi all,
i hav a strange requirement.but it'll be easy.it's actually inside my JSP page.but it's only related to HTML or javascript.
i hav 3 textfields for searching.that is ,
1)products textfield(user can enter product name then click search)
2)company textfield(user can enter company name then click search)
3)category textfield(user can enter company name then click search)
put value in any textfield and click search.that will bring search results.
now i wanna change this to one textfield and a listbox.user can type in textfield and select an option(products or company or category)then click search.
how to make it possible?.
i wanna make all names of <input> tags as same before.i wanna change the name of textfield according to the listbox selection.that i think the quick trick.
anyone plz help
thanks in advance
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Here is the basic idea, I added an onclick on the text bo so you can see how the name changes.

You are just going to have to adapt the code slightly for your application.
Eric
Murasoli Maran
Ranch Hand

Joined: Jun 08, 2003
Posts: 193
hi Eric,
now the problom is,
i have cut and pasted ur code into my JSP page.
javascript function is pasted inside <head></head>tags and HTML pasted inside <body>tags.
first i got an error message like this
document.Test.D1 is null or not an object.
then i hav changed document.Test.D1 to document.forms[0].D1
now the problom is options is null or not an object.
do u tell me the possible causes for this problom?.how can i resolve this problom?.
appreciating ur help.Eric.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
I changed the code to this:

And it still works.
Things to look at:
Is there 1 or more form tags on the page.
Did you change the name of the dropdown from D1 to something else?
Eric
Murasoli Maran
Ranch Hand

Joined: Jun 08, 2003
Posts: 193
Hi eric,
thanks a lot.u sent me exactly what i meant.but it would'nt played the trick.
i need ur Validity code.i tried to download it but some error.do u sent me through javaranch?.
with regards,
Murasoli Maran
Ranch Hand

Joined: Jun 08, 2003
Posts: 193
i got the validity code..thanks
 
wood burning stoves
 
subject: textbox to listbox(simple)