|
|||||||
| JavaScript JavaScript (not Java) Discussion and technical support, including AJAX and frameworks (JQuery, MooTools, Prototype...) |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
javascript navigation pulldown menus
hey all,
got a quick one.. i am using a javascript pulldown menu and it works fine. The only problem is that I want the "GO" button to be a pic instead of the standard windows go button. Every time i try to change it to a picture though, the script breaks. Any suggestions, code ex's below. external .js file: function formHandler(){ var URL = document.form.site.options[document.form.site.selectedIndex].value; window.location.href = URL; } document.write('<form name="form">'); document.write('<select name="site" size=1 style="border:1px solid #000000; font-family: arial,helvetica; font-size: 11px; height: 19px; width: 140px;float:right; background-color:#767676; color:#FFFFFF">'); document.write('<option value="">Choose Below↓'); document.write('<option value="http://www.productsiege.com/page_promos/christian_products_promo.htm">Christian Products'); document.write('<option value="http://www.productsiege.com/page_promos/harry_potter_promo.htm">Harry Potter'); document.write('<option value="http://www.productsiege.com/page_promos/ipowerweb_hosting_promo.htm">iPowerWeb Hosting'); document.write('<option value="http://www.productsiege.com/page_promos/michael_thurmonds_6_week_body_makeover_promo.htm">6 Week Body Makeover'); document.write('</select>'); document.write('<input type="image" src="images/index/shopping_search_go.gif" border="0" align="left" width="25" height="25" onClick="javascript:formHandler()">'); document.write('</form>'); Code Embedded in body of Page: <script language="JavaScript" src="includes/menu.js"></script> Everything works great right up until the point that i change the input type to an image. See it in action here, http://www.productsiege.com/index2.htm Thanks in advance for any help. |
|
#2
|
|||
|
|||
|
An input type of image is used for submitting forms that may be why the onClick is not working correctly. Try this:
document.write('<a href="javascript:formHandler()"><img src="images/index/shopping_search_go.gif" border="0" align="left" width="25" height="25">'); |
|
#3
|
||||
|
||||
|
Yeah, I think the reason you were having an error is because of the way you fire your function. If you call it on an event (like onclick), you don't need to include the "javascript:"
That's used in href tags (like rc's solution). In an event, simply call formHandler(). Also, javascript: has no space. document.write('<img src="images/index/shopping_search_go.gif" border="0" align="left" width="25" height="25" onClick="formHandler()">'); - Ian |
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|