Print Page | Close Window

Combining ASP and Javascript

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=6771
Printed Date: 31 March 2026 at 6:23pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Combining ASP and Javascript
Posted By: Epon
Subject: Combining ASP and Javascript
Date Posted: 28 October 2003 at 12:45am

Hi,

I'm having trouble with using a Javascript value in ASP. In my asp page I have a form:

<form name="form">

<input type="text" name="country">

<input type="submit" name="submit" onclick="return cmdSubmit_onclick()">

</form>

On top of my asp page I have a Javascript function link this:

function cmdSubmit_onclick() {

ctry = document.form.country.value

if (ctry!="")

{

<% strSQL = "SELECT Country FROM SC WHERE Country = " &ctry%>

}

}

My question is how do I use the value of ctry in ASP?

Really appreciate if someone could help me.

Thanks




Replies:
Posted By: 3BEPb
Date Posted: 28 October 2003 at 2:33am

No way, AFAIK. Javascripts executes on client, but vbscript in your case executes on server, i.e. before javascript. The only solutions is to load all countries from database and make javascript array out of them, and then select proper country by js from js array.

So, since ASP is executing vbscript first means you can dynamically build javascript out of asp (let's say database records), but tot vice versa.



Posted By: JoeP
Date Posted: 31 October 2003 at 2:34pm

can submit the form to the same page:

<form name="form" method=post action="thispage.asp>

Capture ctry in code:

ctry = request.form("ctry")

then perform sql action.




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net