|
-
Aug 16th, 2000, 07:50 AM
#1
Thread Starter
New Member
I'm new to ASP and need some help.
I've got an asp page that does some validation and then
I pass a variable to a Client Side Java Script function.
The JS function does not recognize the ASP variable.
I tried using "document.all['<%=ASPVariableName%>'].value"
with no success.
The only way I found to pass anything to the JS function
is to create a hidden field on the form and reference it
like "form.HiddenFieldName.value"
Any suggestions would be greatly appreciated.
-
Aug 16th, 2000, 08:08 AM
#2
Addicted Member
Hi,
Without seeing your code, it's hard to work out where you want the variable names to go.
If you just want to put the ASP variable into a JS variable then try
Code:
MyVar = <% Request.QueryString("ASPvariable") %>
or if you are using it to reference a field in a form:
Code:
document.all.form1.<%Request.QueryString("ASPvariable")%>.value
Again, without your code I really don't know what you are trying to do but I hope this helps!
Shaun
Web/Application Developer
VB6 Ent (SP5), Win 2000,SQL Server 2000
-
Aug 16th, 2000, 08:10 AM
#3
Addicted Member
oops...should be <% Response.Write Request.QueryString("ASPvariable") %>
Web/Application Developer
VB6 Ent (SP5), Win 2000,SQL Server 2000
-
Aug 17th, 2000, 03:00 AM
#4
Hyperactive Member
is there any place to see more of the code ?
After the page is loaded, right click on the browser, and click the "view source" see if there is anything in the JavaScript that is wrong (like the variable value missing or something).
try putting a
response.write (request ("variable")) at the begining of the page, and see if you can see the value.
The JavaScript / HTML don't even know it is an ASP page, so there is no diffrence if you use the ASP in JavaScript or in HTML, the ASP is being proccessed before the page is loaded (Server side).
In the beginning the universe was created. This has made a lot of people very angry and is generally regarded as a bad idea.
- Douglas Adams
The Hitchhiker's Guide to the Galaxy
-
Aug 17th, 2000, 01:28 PM
#5
Addicted Member
yeah, if you need values from ASP, just define them outside your JS function, assign them values using simple ASP statement, and then pass them into your JS function.
dvst8
Secret to long life:
Keep breathing as long as possible.
-
Aug 17th, 2000, 01:30 PM
#6
Addicted Member
asabi is absolutely right.
the ASP is processed way before any client-side JS gets processed.
that's why JS and ASP don't work togehter.
dvst8
Secret to long life:
Keep breathing as long as possible.
-
Aug 17th, 2000, 01:38 PM
#7
Addicted Member
Hi,
We have solved the problem now! but thnx anyway. The way (and the only way I believe) to pass the ASP variable to the Javascript variable was top put this in the ASP page:
Code:
dim aBaseURL
BaseURL="Http://VB-world.net"
Response.Write("<Script>")
Response.Write("var jBaseURL='" & aBaseURL & "'")
Response.Write("</Script>")
which then showed up on the HTML page as:
Code:
<Script>
var jBaseURL='Http://VB-world.net'
</Script>
He could then access this Javascript variable as he would any other.
There was more stuff to it as well but that is how I did that bit!!! 
Cheers,
Shaun
Web/Application Developer
VB6 Ent (SP5), Win 2000,SQL Server 2000
-
Aug 17th, 2000, 03:17 PM
#8
Thread Starter
New Member
Thanks Shaun. It worked just fine.
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
|