Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using dropdown box in JavaScript

 
Brijesh Shah
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Brijesh Shah
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64700
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[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]
 
Yuriy Fuksenko
Ranch Hand
Posts: 413
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Brijesh Shah
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 413
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<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>
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic