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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

is it possible to mix javascript and asp?

Status
Not open for further replies.

taval

Programmer
Jul 19, 2000
192
GB
I currently have code that extract of code that looks like this:

<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
<!-- Start Hiding the Script

var alreadyWarned = false;
function deleteFunction() {
value = confirm(&quot;File Record ID : <%=form_FileID%> relating to Customer Record ID : <%=valCustId%> will be deleted. Proceed? &quot;);
alreadyWarned = true;
if (value) {
can I put asp code here
can I put asp code here
can I put asp code here

alert(&quot;It would have been deleted.&quot;);
}


}

// Stop Hiding script --->
</SCRIPT>

</Table>
<%

I would like to know if its possible to mix javacscript with asp code, I have tried putting <% %> around asp code in the part I mention but I get errors.

Grateful for any help.
Thanks.
 
if the javascript is client side then nope, if it's serverside then yea. based on the example you given.
Sorry couldnt be more detailed at this moment, but I think you get the point.
 
ASP code runs on the server, so by the time the client browser gets the page source, the ASP has already been processed. You'll have to submit the page if you need to validate something on the server.

However, you might be able to use remote scripting. Check it out at the microsoft site.
 
With my original post the problem I had is that the server processed all the asp code regardless of whether it was embedded in Javascript which seems right to me. I know I can do it with a submit button. But what I wanted was a confirmation box (thats the javascript bit) that asked confirmation for deletion and if it was confirmed then asp script would carry out the procedure. Can I make a submit button without having the button and just plain text (like a link) ? And then when a I click the subit button , can I have a confirmation box for that?

Grateful for any help, thanks.
Taha
 
You could do something like this:
<script language=javascript>
function doSubmit(){
if (confirm('Really Delete It?'))
document.forms[0].submit();
}
</script>
<a href='javascript:doSubmit()'>Click to submit</a>
 
how would I tell it which page to submit to?
 
um, that depends on what yer doing, it's most likely going to submit to one of your ASP pages, where it can process the information there.
 
ok with this code:

-----------
<script language=javascript>
function doSubmit(){
if (confirm('Really Delete It?'))
document.forms[0].submit();
}
</script>
<a href='javascript:doSubmit()'>Click to submit</a>
----------------------

where would I tell it I want to submit the information to the asp page decustomer.asp
 
You need to tell it in the form[0]'s action attribute. If form[0] on your document has a name, say &quot;form1&quot;:
<form name=&quot;form1&quot; action=&quot;decustomer.asp&quot; method=&quot;post&quot;>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top