|
-
Oct 28th, 2002, 11:53 PM
#1
Thread Starter
Addicted Member
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.
-
Oct 29th, 2002, 03:13 AM
#2
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>
-
Oct 29th, 2002, 03:57 PM
#3
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.
-
Oct 29th, 2002, 11:17 PM
#4
Thread Starter
Addicted Member
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
-
Oct 30th, 2002, 12:38 AM
#5
-
Oct 30th, 2002, 10:48 AM
#6
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|