Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding the value of an input element to an anchor tag

Status
Not open for further replies.

clydejones

Programmer
Jan 11, 2001
153
US
Hi All,

Not sure if this is the correct place to ask this question,
but I am trying to add a value from an input element on my asp page named "FromDate" with the following code.

response.Write(&quot;<a href = test.asp?FromDate=&quot;&document.txtFromDate.Value&&quot;>This is the FromDate link</a>&quot;)

However, I get the following error message. Variable is undefined: 'document'. Can anybody tell me what's going on and how to add the FromDate value to the anchor tag before I loose my mind?

Thanks,
clyde
 
Sounds like a job for the ASP Forum actually.

Your basic problem is that you don't have an input element on your ASP page - ASP pages can't have elements. You also don't have an object called document to play with on your ASP page.

In general, an ASP page is a script-ridden template for an HTML page. ASP accepts a request and interprets it by emitting literal HTML and processing embedded script which may (or may not) emit more HTML via Response.Write( ).

When this HTML is received and interpreted by a browser such as IE (which can involve processing more script client-side), you finally have a &quot;document.&quot; Only then can there be input elements and an object named document - and they live in the browser where script in ASP pages cannot see them no matter how hard they might try.

Is the ASP code you show above part of a page that a previous browser document did a GET or POST to?

If so, the input element back at the browser should have had its value sent to this ASP code via the Request.Form collection or the Request.QueryString collection.

See:

 
dilettante,

Thanks for your reply. Actually this ASP page had HTML and ASP tags on it. The element I was trying to get the value of was within the HTML tag of the same ASP page. I think I understand that I could not get the value unless it had been sent to the ASP page. I thought the ASP portion of the page could see the HTML portion of the page without it being sent. Thanks for the explanation. I have now accomplished my problem by using javaScript.

Clyde
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top