aspose file tools*
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
Author

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: 15286
    
    6

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


GenRocket - A Test Data Generation Platform
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 window.open call.

function openwindow1()
{
MyWindow1=window.open("Comboimage/Comboimage1.html","","toolbar=yes,location=yes,"+
"directories=yes,status=yes,menubar=yes,scrollbar=yes,resizable=yes,width=475,height=475")
}//closing the function openwindow1()
function openwindow2()
{
MyWindow2=window.open("Comboimage/Comboimage2.html","","toolbar=yes,location=yes,"+
"directories=yes,status=yes,menubar=yes,scrollbar=yes,resizable=yes,width=475,height=475")
}//closing the function openwindow2()
function openwindow3()
{
MyWindow3=window.open("Comboimage/Comboimage3.html","","toolbar=yes,location=yes,"+
"directories=yes,status=yes,menubar=yes,scrollbar=yes,resizable=yes,width=475,height=475")
}

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

Joined: Jan 10, 2002
Posts: 60053
    
  65

[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="window.open(this.options[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
<script>
function openwindow(url)
{
MyWindow1=window.open("Comboimage/Comboimage1.html","","toolbar=yes,location=yes,"+
"directories=yes,status=yes,menubar=yes,scrollbar=yes,resizable=yes,width=475,height=475")
}
</script>
<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>
</select>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Using dropdown box in JavaScript
 
Similar Threads
not to allow closing current window..
HttpSession Object creation with mulitple browser windows
Comment on GUI..
Opening HTTPS link in same popup
How can I open a JSF page as a non modal dialog