JS Problem

J

James Baker

I'm having a problem with JavaScript and ASP that need to be intermixed.
I'm querying a database, and creating JavaScript arrays for use on the
client side...which works fine. Basically I have two drop down lists, and
when you select an item in the first drop down, the items in the second one
change. The functionality there is no problem.

My problem lies in the fact that I'm embedding ASP code within a javascript
function, and it's causing my form to post every time I try to do validation
or some other client side function. Is there a simple way around this?

Thanks,
James
 
J

joker

I sounds like your javascript is doing a http submit. At least that is
my guess without any code.

At this point to do anything other then guess we will need to see some code.
 
J

James Baker

<script language="javascript">
var formTypes = new Array();
<%
' Code to write out arrays here
%>
</script>

....

<script language="Javascript">
<!--
function validater()
{
// FormType must be selected
if (document.appraisalorder.formtype.value.length <= 1)
{
alert("Please select a Form type.")
document.appraisalorder.formtype.focus();
return false;
}

document.appraisalorder.action = 'Order_Submit.asp';
window.document.appraisalorder.submit();
return true;
}
-->
</script>

....

<input type="image" name="Submit" src="../../../images/submitfile.gif"
alt="Submit File" border="0" onclick="validater()">


When I click the button named Submit, it fires the validater function. If
the form type isn't selected, it does the alert, but the page "refreshes"
and definitely hits the server again.

James
 
E

Evertjan.

James Baker wrote on 11 aug 2004 in
microsoft.public.inetserver.asp.general:
window.document.appraisalorder.submit();
return true;

Though it has nothing to do with ASP and so is OT:

Both the above '...submit()' and the 'return true;'
will compete which code is fastest internaly to submit your form.
This will potentially lead to dissastrous and inconsistent behavour.

Please ask a Javascript NG for these clientside problems.
 
J

James Baker

The return true is essentially irrelevant, I had intended to comment it out.
I have asked in a javascript newsgroup and will post in
microsoft.public.scripting.jscript. It appears to be a conflict between ASP
and jscript so I figured I'd post it to both. My apologies for filling your
newsgroup with OT posts.
 
E

Evertjan.

James Baker wrote on 11 aug 2004 in
microsoft.public.inetserver.asp.general:
The return true is essentially irrelevant, I had intended to comment
it out. I have asked in a javascript newsgroup and will post in
microsoft.public.scripting.jscript. It appears to be a conflict
between ASP and jscript so I figured I'd post it to both. My
apologies for filling your newsgroup with OT posts.

Not at all, James, it is not my or even our NG.

If you can show us why you suspect a serverside ASP conflict with
clientside j(ava)script [btw, ASP can in jscript, vbscript, and perhaps
other languages] You are totally OT [= ON-topic in this case] here.

===========

I do not trust the javascript submit() to be so fast or single tasking,
that the html-form-submit will not interfere on any current browser.
 
M

Mark Schupp

<form name="theform" onsubmit="return validater();" ....

<input type="image" name="Submit" src="../../../images/submitfile.gif"
alt="Submit File" border="0" onclick="document.theform.submit();">
 
B

Bã§TãRÐ

An image is usd as a submit button in JavaScript. The OnClick event shouldnt even be needed.

Bastard
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top