File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes HTML, CSS and JavaScript and the fly likes Using dropdown box in JavaScript 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 "Using dropdown box in JavaScript " Watch "Using dropdown box in JavaScript " New topic

Using dropdown box in JavaScript

Brijesh Shah
Ranch Hand

Joined: Aug 08, 2006
Posts: 34
Please tell me how to use Combo items as links which will open another window and display the appropriate page.
Here we have to use the function for the combo links to open another window....
[ August 09, 2006: Message edited by: Vicky Shah ]
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299

Call a function with the onchange attrib of the SELECT element. In that onchange event function, do a call passing in parameters as appropriate for the new window.

GenRocket - Experts at Building Test Data
Brijesh Shah
Ranch Hand

Joined: Aug 08, 2006
Posts: 34
Hi Gregg,

I did the same thing what you have suggested in the Select tag using the OnChange event and passed the parameters for my new Window using the call.

function openwindow1()
}//closing the function openwindow1()
function openwindow2()
}//closing the function openwindow2()
function openwindow3()

<OPTION NAME="windowform1" ONCHANGE="openwindow1()">Traffic</OPTION>
<OPTION NAME="windowform2" ONCHANGE="openwindow2()">Businessmen</OPTION>
<OPTION NAME="windowform3" ONCHANGE="openwindow3()">Tall Buildings</OPTION>
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 60782

[Bear moves his sopabox into position]

Just for the record, there is no such thing as a "Combo box" in HTML. A <select> element is not a Combo Box. A Combo Box is a desktop UI element in which the user can either choose from a dropdown option or type their own value into the control. HTML does not have such a native control.

You can call it a select element, or you can call it a dropdown, but please do not call it a Combo Box.

I'll be quiet now.

[Bear steps down from the soapbox]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Yuriy Fuksenko
Ranch Hand

Joined: Feb 02, 2001
Posts: 413
Brijesh Shah
Ranch Hand

Joined: Aug 08, 2006
Posts: 34
Hi Yuriy,
You suggested me to use the code below for the above isssue but its not working for my coding.

<select onchage="[this.selectedIndex].value,'testWindow')"><option value="page1.html">page1</option><option value="page2.html">page2</option><option value="page3.html">page3</option></select>

Please can you suggest for my code how can I use the above for my coding?
My code is given above.
Thanks in addvance........
Yuriy Fuksenko
Ranch Hand

Joined: Feb 02, 2001
Posts: 413
function openwindow(url)
<select onchange="openwindow(this.options[this.selectedIndex].value)">
<option value="Comboimage/Comboimage1.html">page1</option>
<option value="Comboimage/Comboimage2.html">page2</option>
<option value="Comboimage/Comboimage3.html">page3</option>
I agree. Here's the link:
subject: Using dropdown box in JavaScript
Similar Threads
How can I open a JSF page as a non modal dialog
HttpSession Object creation with mulitple browser windows
Opening HTTPS link in same popup
Comment on GUI..
not to allow closing current window..