Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - ASP and JavaScript
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

ASP and JavaScript

 Post Reply Post Reply
Author
Phat View Drop Down
Senior Member
Senior Member


Joined: 23 February 2003
Status: Offline
Points: 386
Post Options Post Options   Thanks (0) Thanks(0)   Quote Phat Quote  Post ReplyReply Direct Link To This Post Topic: ASP and JavaScript
    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>



Back to Top
Gullanian View Drop Down
Senior Member
Senior Member
Avatar

Joined: 04 January 2002
Location: England
Status: Offline
Points: 4373
Post Options Post Options   Thanks (0) Thanks(0)   Quote Gullanian Quote  Post ReplyReply Direct Link To This Post 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>

Back to Top
Phat View Drop Down
Senior Member
Senior Member


Joined: 23 February 2003
Status: Offline
Points: 386
Post Options Post Options   Thanks (0) Thanks(0)   Quote Phat Quote  Post ReplyReply Direct Link To This Post 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>")

Back to Top
Gullanian View Drop Down
Senior Member
Senior Member
Avatar

Joined: 04 January 2002
Location: England
Status: Offline
Points: 4373
Post Options Post Options   Thanks (0) Thanks(0)   Quote Gullanian Quote  Post ReplyReply Direct Link To This Post 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

Back to Top
Demon View Drop Down
Mod Builder Group
Mod Builder Group
Avatar
Mod-n-Skin Moderator

Joined: 26 July 2003
Status: Offline
Points: 299
Post Options Post Options   Thanks (0) Thanks(0)   Quote Demon Quote  Post ReplyReply Direct Link To This Post 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?
Back to Top
Gullanian View Drop Down
Senior Member
Senior Member
Avatar

Joined: 04 January 2002
Location: England
Status: Offline
Points: 4373
Post Options Post Options   Thanks (0) Thanks(0)   Quote Gullanian Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
Phat View Drop Down
Senior Member
Senior Member


Joined: 23 February 2003
Status: Offline
Points: 386
Post Options Post Options   Thanks (0) Thanks(0)   Quote Phat Quote  Post ReplyReply Direct Link To This Post 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


Edited by Phat - 19 January 2005 at 2:53am
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.