asp + dom + html help

Dec 29, 2005
89
0
0
i've never used asp before (i'm a java programmer). i am working on a web form that posts information to itself and i want to call a dom method (document.getelementsbyname()) within the asp code, but i always get an error. using just javascript or vbscript i can do it fine.

i have a form input text named mytext and i want to set the value of that text to be what was submitted by the user

i have it working right now where i just have the line where i write the html output from asp and i just put the value attrib of the input to be the value, but i wanted to use dom to do it. i can do the same thing from vbscript or javascript. but when i try to insert the same code into the asp fragment it gives an error. is this possible? is there another way i should/could be doing this.

thank you to anyone for helping out here
 

MrChad

Lifer
Aug 22, 2001
13,507
3
81
JavaScript and VBScript are client-side languages, while ASP is a server-side language. Your ASP cannot manipulate the DOM, because the DOM isn't created until the ASP has finished executing and the resulting HTML is delivered to the browser. The browser builds the DOM from the HTML it receives, and it's script engine has access to those DOM objects.

You can still accomplish what you're describing. In your ASP, you probably have:

<input type="text" name="mytext" value="">

You can change it to this:

<input type="text" name="mytext" value='<%=Request.Form("mytext") %>'>

to set it to the value submitted by the user (assuming that this is a postback page and Request.Form("mytext") contains the value you're looking for).
 
Dec 29, 2005
89
0
0
Originally posted by: MrChad
JavaScript and VBScript are client-side languages, while ASP is a server-side language. Your ASP cannot manipulate the DOM, because the DOM isn't created until the ASP has finished executing and the resulting HTML is delivered to the browser. The browser builds the DOM from the HTML it receives, and it's script engine has access to those DOM objects.

You can still accomplish what you're describing. In your ASP, you probably have:

<input type="text" name="mytext" value="">

You can change it to this:

<input type="text" name="mytext" value='<%=Request.Form("mytext") %>'>

to set it to the value submitted by the user (assuming that this is a postback page and Request.Form("mytext") contains the value you're looking for).

yeah, that's what i'm doing now. it just seemed like there would be a bette way to do that.