Win a copy of Succeeding with AI this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Junilu Lacar
Sheriffs:
  • Tim Cooke
  • Jeanne Boyarsky
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • fred rosenberger
  • Frits Walraven

Using dropdown box in JavaScript

 
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 ]
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • 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>
 
Sheriff
Posts: 67389
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • 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]
 
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>
 
I am going down to the lab. Do NOT let anyone in. Not even this tiny ad:
Two software engineers solve most of the world's problems in one K&R sized book
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic