Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

onclick ="submit()" not working on IE 5.0

Status
Not open for further replies.

acidkewpie

Programmer
Nov 19, 2003
25
0
0
GB
Hi, i have the following chunk of code in a web app:

</div>
<span id=branch>
<div class=left>Please enter a branch number to connect to:</div>
<div class=left>
<form method=post name=branchnumberform>
<input name=BranchNumber value=&quot;<%=Session(&quot;Branchnumber&quot;)%>&quot;>
<a class=&quot;button&quot; href=&quot;#&quot; onclick=&quot;document.branchnumberform.submit()&quot;>submit</a>
</form>
</div>
<div class=right>
<span id=sessionstarted>Session Started:<br><%=Session(&quot;started&quot;)%></span>
</div>
</div>
<div id=sidemenu>
</div>

this all works lovely in ie 5.5 and later, but does not do anything when clicking the submit link on IE 5.0. the vbscript is working though. for example:

i can change it to &quot;msgbox('test')&quot; and the box WILL appear
i can spell the &quot;submit&quot; wrong and get vbscript errors

yet on 5.0 it will not work. the url changes, to add the # so that's fine, yet nothing actually changes. I have been on google and not found any issues about this... is it a known limitation?

thanks

Chris
 
actually i've found that changing to a get rather than a post will work.... which will take ages to change and it undesirable in general. any suggestions? I guess this isn't technically a vbscript problem now though.

Chris
 
oh stupid me... no it dopesn't make any difference after all... why can't i edit the posts? ack!
 
I'm not too sure what might be going wrong here, or why it seems to work in IE 5.5 but not 5.0 or some other version.

What (if anything) happens when you try the following two changes?

Change #1:

</div>
<span id=branch>
<div class=left>Please enter a branch number to connect to:</div>
<div class=left>
<form method=post id=branchnumberform>
<input name=BranchNumber value=&quot;<%=Session(&quot;Branchnumber&quot;)%>&quot;>
<a class=&quot;button&quot; href=&quot;#&quot; onclick=&quot;document.branchnumberform.submit()&quot;>submit</a>
</form>
</div>
<div class=right>
<span id=sessionstarted>Session Started:<br><%=Session(&quot;started&quot;)%></span>
</div>
</div>
<div id=sidemenu>
</div>

Change #2:

</div>
<span id=branch>
<div class=left>Please enter a branch number to connect to:</div>
<div class=left>
<form method=post name=branchnumberform>
<input name=BranchNumber value=&quot;<%=Session(&quot;Branchnumber&quot;)%>&quot;>
<a class=&quot;button&quot; href=&quot;#&quot; onclick=&quot;Javascript:document.branchnumberform.submit()&quot;>submit</a>
</form>
</div>
<div class=right>
<span id=sessionstarted>Session Started:<br><%=Session(&quot;started&quot;)%></span>
</div>
</div>
<div id=sidemenu>
</div>

First try change 1, then try change 2, then try them together.

The first change attempts to deal with a common misconception that name is the same as id. It is not, though in most cases IE will coerce the element's id to be the same as the name value if the author fails to provide an id value.

The second one forces the inline &quot;Javascript-style&quot; event handler to use Javascript/JScript even if the page-default scripting language has somehow been set to VBScript or something else.


You also may be letting the default action for onClick sneak through. Maybe this is where the browser versions are behaving differently? Normally in a case like this you'll want something like:

onclick=&quot;Javascript:document.branchnumberform.submit();return(false)&quot;

This is about the same as:

onclick=&quot;Javascript:document.branchnumberform.submit();window.event.returnValue=false&quot;>

It cancels the default action associated with the onClick event after peforming your desired action.


All three of these are good changes to make to your ASP page though.

But this is all Javascript as you said, not VBScript. ;-)
 
you are a truly beautiful human!

seems it was the default action, i added the equivalent vbscript changes and it works like a charm.

thanks so much

Chris
 
Well I appreciate the good words and I'm glad you're able to move forward with your project.

But I doubt my ex-wife would agree with that &quot;beautiful human&quot; part! ;-)

You're very welcome.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top