Javascript / browser question

T

Thom.Burnett

I want to change an action based on values in a form.
The following javascript code works great in Firefox but not Internet
Explorer.
With IE the default action is always used by submit.

Any ideas why or suggestions on how to get it to work?
Please copy any answer to (e-mail address removed)

<script language="JavaScript" >
function setAction() {
var actionPath=document.mainForm.server.value ;
alert("actionPath is " + actionPath) ;
document.forms[0].action = actionPath ;
document.mainForm.action=actionPath ;
}
</script>
....
<form name="mainForm" action="http://192.168.5.80/cffprod/api/
proc" enctype="multipart/form-data" method="post"
onsubmit="setAction">
<br/>
Enter a container URL. <br/>
The default is for test. <br/>
The standalone uses: http://localhost:8888/apiServlet/proc <br/>
<input type="text" name="server" value="http://192.168.5.80/
cffprod/api/proc" size="60" onchange="setAction()" />
<br/>
 
S

scripts.contact

Thom.Burnett said:
I want to change an action based on values in a form.
The following javascript code works great in Firefox but not Internet
Explorer.
With IE the default action is always used by submit.

Any ideas why or suggestions on how to get it to work?

Try this:

<script>
function setAction(form) {
var actionPath=form.server.value ;
form.action = actionPath ;
}
</script>
....
<form name="mainForm" ... onsubmit="setAction(this)">
Enter a container URL. <br/>
The default is for test. <br/>
The standalone uses: http://localhost:8888/apiServlet/proc <br/>
<input type="text" name="server" ....
onchange="setAction(this.form)" />
<br/>
Please copy any answer to (e-mail address removed)

Focus the message in your newsreader. Press Ctrl+A, Right click and
choose Copy.
Open your mail-app, click Compose, right-click and select Paste. Enter
your email address in To field and click Send.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top