Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Jan 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Passing Variable

    Can Someone please help me how to pass jscript(str variable) to asp (strvar).

    <Script>
    function cmbSelect()
    {
    var w = document.log.Combo.selectedIndex;
    var str = document.log.Combo.options[w].text;
    }
    </Script>

    I want the str variable to be
    <%strVal = str %> ------------------ This is code gives me error. Can you help me with this. Thank You.
    Last edited by New4JsnVb; 01-23-2005 at 03:05 AM.

  • #2
    New Coder
    Join Date
    Jan 2005
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    try with request.form() object

    i am not sure means i have not try but may be poosible with

    request.form() object.

    if this will run than replay me......



  • #3
    New Coder
    Join Date
    Jan 2005
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hey first tell are you want this value without refreshing your page???????

    if yes than its possible using request.form() object.

    if no than you have to make array of javascript using asp at onload
    example:
    response.write("<script>")
    response.write("var a")
    response.write("a="&abc)
    response.write("</script>")
    here abc is asp variable of which u want value.

    sonal is here.....

  • #4
    New to the CF scene
    Join Date
    Jan 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you sonal. i tried what you gave me but still it didnt work. I will aprreciate anybody who could help me with this. Thank you in advanced.

  • #5
    Senior Coder
    Join Date
    Apr 2003
    Location
    England
    Posts
    1,192
    Thanks
    5
    Thanked 13 Times in 13 Posts
    errm... to pass a client side variable to a server side variable you need to send the variable as a form or querystring element, then read it on the serverside, ie

    <form name="f" method="post">
    <input type="hidden" value="" name="str">
    </form>

    then either use a submit button on the form (in which case the form doesnt need a name) or use a link that runs document.f.submit()

    this can then be read when the page reloads with Request.Form("str")

    unrelated:
    response.write("<script>")
    response.write("var a")
    response.write("a="&abc)
    response.write("</script>")
    ps, you dont need parenthesis in the Response.Write unles u are using ye olde asp, and you dont need to write each line on a separate line of asp, you need one on each line of javacript however (well you wouldnt if semicolon worked the way it does in java, and how its sposed to in javascript *shakes fist at the air*)
    Code:
    abc = "blah"
    Response.Write "<script>" & vbNewLine & "var a = " & abc & ";" & vbNewLine & "</script>


  •  

    Posting Permissions

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