File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes Dropdown List and Command button 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 "Dropdown List and Command button" Watch "Dropdown List and Command button" New topic
Author

Dropdown List and Command button

Todd Kanipe
Greenhorn

Joined: Jan 05, 2009
Posts: 2
Hello, I am having a compatibility problem with a drop down list and Firefox. The obvious fix is a little JavaScript that I can't seem to get to work.

I have a drop down list that the user will select from. On the click of a button (image), I need to go to the new url.

This is my original code that doesn't work with Firefox; anybody know how to make it compatible?
<form name="frmSelectLicense">
<DIV>
<select name="mylicensebox">
<option value="/code-128-barcode-font.aspx">Select License Type</option>
<option value="/code-128-barcode-fonts-1U.aspx" selected="selected">One User License ($95)</option>
<option value="/code-128-barcode-fonts-10U.aspx">Ten User License ($190)</option>
<option value="/code-128-barcode-fonts-100U.aspx">One Hundred User License ($380)</option>
</select>
</DIV>
<DIV>
<a href="#" OnClick=location.href=mylicensebox.value>
<IMG src="/graphics/buy-now.gif" alt="Buy PrecisionID Code 128 Barcode Fonts" border="0" title="Buy Code 128 Barcode Fonts">
</a>
</DIV>
</form>


I found and adapted this JavaScript but the jump occurs with selection, not the click of the "buy-now" image. Any help is appreciated.
<script type="text/javascript">
function jump(objSelect){
if (objSelect.selectedIndex<=0) return false;
var objOpt = objSelect.options[objSelect.selectedIndex];
window.location.href=objOpt.value;
}
</script>
<select onChange="jump(this);">
<option value="/code-128-barcode-font.aspx">Select License Type</option>
<option value="/code-128-barcode-fonts-1U.aspx">One User License ($95)</option>
<option value="/code-128-barcode-fonts-10U.aspx">Ten User License ($190)</option>
<option value="/code-128-barcode-fonts-100U.aspx">One Hundred User License ($380)</option>
</select>
</div>
<div>
<a href="#" OnClick=location.href=mylicensebox.value>
<IMG src="/graphics/buy-now.gif" alt="Buy PrecisionID Code 128 Barcode Fonts" border="0" title="Buy Code 128 Barcode Fonts">
</a>
</div>
stef li
Greenhorn

Joined: Jan 16, 2006
Posts: 27
try to change your code below:


to


This guy is so lazy!!!<br />There is nothing left!
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61218
    
  66

Todd Kanipe, please be sure to use code tags to highlight your code (rather than blue text).


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
HTML tags and attribute names are to be written in all lowercase.
HTML attribute values are to be surrounded with double quotes.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
You need to use

when referencing an element.
Eric
Todd Kanipe
Greenhorn

Joined: Jan 05, 2009
Posts: 2
Thank you all for the help. I've finally gotten it to work. It turnout there there was another form declared in the code that was messing with my addition. Once I figured that out, I was able to adjust. Again, Thanks!!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Dropdown List and Command button