Jump to content

How do I use a form to trigger a javascript?


kanala

Recommended Posts

<form action="java script:ShowContent" METHOD="POST" onSubmit="return dropdown(this.gourl)"><select NAME="gourl"><option VALUE="" selected="selected">Select animal</option><option VALUE="java script:ShowContent('pros')">Bear</option></select><input TYPE="SUBMIT" VALUE="Go"></form>I don't know if I have the form action and onsubmit bit right. The javascript command should be "java script:ShowContent('pros')", which should be triggered when you choose the option "Bear" and press Go.

Link to comment
Share on other sites

<form onSubmit="ShowContent(this.gourl.value); dropdown(this.gourl); return false;"><select NAME="gourl"><option VALUE="" selected="selected">Select animal</option><option VALUE="pros">Bear</option></select><input TYPE="SUBMIT" VALUE="Go"></form>

Link to comment
Share on other sites

Thanks, now I need some more help.This is the script to get the photo album in freewebs.<link rel="stylesheet" type="text/css" href="http://www.freewebs.com/icegifts/slidesDefault.css"><script src="http://images.freewebs.com/WebsAlbum/websAlbumUtils.js" type="text/javascript"></script><script src="http://www.freewebs.com/icegifts/miniaturesallphoto.js" type="text/javascript"></script><script src="http://freewebs.com/icegifts/slides.js" type="text/javascript"></script><script type="text/javascript">drawWebsAlbum();</script>Is there a way (javascript command) to change the <script src="http://www.freewebs.com/icegifts/miniaturesallphoto.js" type="text/javascript"> to another src? e.g. "http://www.freewebs.com/icegifts/miniaturesallphoto2.js".I need it to be triggered by pressing a link or by using that drop down menu above.Thanks

Link to comment
Share on other sites

You can get at script elements using the DOM.

<script id="PhotoScript" src="some.js"></script><script>document.getElementById("PhotoScript").src = "someother.js";</script>

However, I can't guarantee that once the src of the script element changes, the browser will recognize that change and fire off any of the code included in the new js file.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...