Results 1 to 6 of 6

Thread: Request thru Javascript variables.

  1. #1

    Thread Starter
    Addicted Member MrPresident2k's Avatar
    Join Date
    May 2002
    Location
    INDIA
    Posts
    167

    Request thru Javascript variables.

    Hi,

    Take a look at this code.
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> 
    <HTML> 
    <HEAD> 
    </HEAD> 
    <script> 
    	var vartxt="txt"; 
    	s = "<%=request(" + vartxt + ")%>";
    	alert(s); 
    </script> 
    <BODY> 
    <form name=f1 action="test.asp"> 
    <input type=text name=txt value="testvalue"> 
    <input type=submit> 
    </form> 
    </BODY> 
    </HTML>
    Iam posting this form and trying to get the value thru a Javascript variable(vartxt). But it isn't working. How can I do this?

    Thanks,
    Pres.

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    You're trying to combine javascript and vbscript on the same line, within SCRIPT tags. This isn't allowed. Here's how to do it in VBScript, you can modify it for JavaScript...

    Code:
    <SCRIPT language=VBScript>
    function extract(var)
    txt=location.href & "&"
    
    pos=instr(1,txt,var)
    
    endpos=len(txt)
    
    
    while not mid(txt,pos,1)="&"
    nvar=nvar & mid(txt,pos,1)
    pos=pos+1
    wend
    
    var=right(nvar,len(nvar)-len(var)-1)
    msgbox (var)
    
    end function
    
    </SCRIPT>

  3. #3
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    I think the real problem is that he is trying to use client-side script and server-side script at the same time, which is by definition totally impossible.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  4. #4

    Thread Starter
    Addicted Member MrPresident2k's Avatar
    Join Date
    May 2002
    Location
    INDIA
    Posts
    167

    Accessing a request

    Hi,

    Iam just trying to access a request from a previous page in this page, and the only difference is Iam trying to form the variable name of the request in my javascript and then assign it to the request.

    Thanks,
    Pres

  5. #5
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    Did that help?

  6. #6
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    The Javascript will be executed after your ASP script.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

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



Click Here to Expand Forum to Full Width