Mixing ASP with JavaScript

Results 1 to 5 of 5

Thread: Mixing ASP with JavaScript

  1. #1
    Bill Anthony Guest

    Default Mixing ASP with JavaScript

    Fellow Developers:<BR><BR>I have learned quite a bit from all of the people who contribute to this excellent messaging resource by simply reading through the posts and replies. Now I have a situation that I am trying to resolve in my own department.<BR><BR>What I am attempting to do is essentially mix ASP code into a JavaScript document reference. The scenario plays out like this:<BR><BR> document.FormName.FieldName.FieldValue<BR><BR>Wher e the "FieldName" and "FieldValue" references are equal to values dynamically generated through ASP. Therefore, the code I am writing looks something like this:<BR><BR> document.FormName.&#060;%=FieldName&#037;&#062;.&# 060;%=FieldValue&#037;&#062;<BR><BR>This does not work. Is there a way to "mix" ASP and Javascript in this manner? Is there an easier way to tackle this issue?<BR><BR>Thanks in advance for acknowledging and replying!<BR><BR>Regards,<BR>Bill Anthony

  2. #2
    Join Date
    Dec 1969
    Posts
    2,849

    Default RE: Mixing ASP with JavaScript

    That should work. Be sure to check View/Source to see what the actual HTML code is. Here is an example:<BR><BR>&#060;%<BR>&#039ASP code/variable<BR>Dim strMessage<BR>strMessage = "Hello, world!"<BR>&#037;&#062;<BR><BR>&#060;SCRIPT LANGUAGE="JavaScript"><BR>// Client side javascript<BR>alert("&#060;%=strMessage&#037;&#062 ;");<BR>&#060;/SCRIPT><BR><BR>This will pop up a message box saying, "hello, world!". Go view the source. See how ASP inserts the string variable into the client-side javascript before the client (web browser) receives anything.<BR><BR>Hope this helps!

  3. #3
    Vipul Suri Guest

    Default RE: Mixing ASP with JavaScript

    Yes You Can Do this try this<BR><BR>function callme()<BR>{<BR>document.myname.&#060;%=session(" name")&#037;&#062;.value=session("value"); <BR>}<BR> <BR>You can mix these scripts,but the document has to contain the controls that you are using

  4. #4
    Vipul Suri Guest

    Default RE: Mixing ASP with JavaScript

    Yes You Can Do this try this<BR><BR>function callme()<BR>{<BR>document.myname.&#060;%=session(" name")&#037;&#062;.value=&#039&#060;%session("valu e")&#037;&#062;&#039 <BR>}<BR> <BR>You can mix these scripts,but the document has to contain the controls that you are using


  5. #5
    Join Date
    Dec 1969
    Posts
    9

    Default RE: Mixing ASP with JavaScript

    Just being technically correct, you missed an equal sign and for<BR>some better clarification on values I changed var names<BR><BR>function callme()<BR>{<BR>document.myform.&#060;%=session(" formelementname")&#037;&#062;.value=&#039&#060;%=s ession("somevalue")&#037;&#062;&#039 <BR>}

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •