Print Page | Close Window

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=13364
Printed Date: 30 March 2026 at 7:51pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: ASP and JavaScript
Posted By: Phat
Subject: ASP and JavaScript
Date Posted: 15 January 2005 at 2:37am
If i have an ASP script is it posible to use JavaScript inside the script to update a value in a text box?

E.g. The ASP code is doing a loop and i want to update a textbox counter. Simmilar to how borg has done it with the mailing list. I need it on the same page as the one i submit it from. I think causes issues as i have copied the way borg did it and it does not work.

When i do it all i get is
<script langauge="JavaScript">document.frmSent.count.value = 1;</script>
<script langauge="JavaScript">document.frmSent.count.value = 2;</script>
<script langauge="JavaScript">document.frmSent.count.value = 3;</script>
<script langauge="JavaScript">document.frmSent.count.value = 4;</script>






Replies:
Posted By: Gullanian
Date Posted: 15 January 2005 at 7:24am
Loop and set the number in a variable then print:

<script langauge="JavaScript">document.frmSent.count.value = <%=varName%>;</script>



Posted By: Phat
Date Posted: 15 January 2005 at 10:34pm
Yeah that uis what i am doing and it print s as above

E.g. Response.Write(vbCrLf & "<script langauge=""JavaScript"">document.frmSent.sen t.value = " & intEmailSentLoopCounter & ";</script>")



Posted By: Gullanian
Date Posted: 15 January 2005 at 11:58pm
Put that line of code outside of the loop, after the end loop statement.  At the moment you have:

Loop
    Print
    Increment counter
End loop


It should be:

Loop
    Increment counter
End loop
Print



Posted By: Demon
Date Posted: 19 January 2005 at 12:32am
I also have a question pertaining to Javascript and ASP.  how would I call an asp function in Javascript tags, and at the same time have the asp function call contain my Javascript variables?


Posted By: Gullanian
Date Posted: 19 January 2005 at 1:44am
Javascript is Client side, ASP is server side.  You can't get Javascript to call and ASP tag in the way you describe.


Posted By: Phat
Date Posted: 19 January 2005 at 2:52am
This is how i go the code above to work


<html>
<head>

</head>

<body>
<form action="" method="post" name="frmCount" id="frmCount">
  <input name="count" type="text" id="count">
</form>
</body>
</html>

<%

Dim intCount

For intCount = 1 to 1000
    Response.Write(vbCrLf & "<script langauge=""JavaScript"">document.frmCount.count.value = " & intCount & ";</script>")
Next

%>



If you do



<%

Dim intCount

For intCount = 1 to 1000

    Response.Write(vbCrLf & "<script langauge=""JavaScript"">document.frmCount.count.value = " & intCount & ";</script>")

Next

%>

<html>
<head>

</head>

<body>
<form action="" method="post" name="frmCount" id="frmCount">
  <input name="count" type="text" id="count">
</form>
</body>
</html>



It will not work. Must have to load the HTML before the asp. Not sure



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