简体   繁体   中英

Having trouble with form requests

I've setup two pages. 1.aspx, and 2.aspx.

on 1.aspx I have a form like so:

<form action="2.aspx" method="post" id="myform">
    <input type="hidden" value="this works" id="mydata" />
    <input type="submit" />
</form>

on 2.aspx I have this code:

Response.Write(Request.Form("mydata"))

This returns nothing.

I also tried

Response.Write(Request.Form(0))

but I get "Index was out of range." Message from the server.

I know I'm probably missing something very simple, but, I can't seem to find it!

What am I doing wrong?

Thanks!

ID is used for client-side access. Give your hidden field name="mydata" for server-side form access

Instead of having

<input type="hidden" value="this works" id="mydata" />

have

<input type="hidden" value="this works" name="mydata" />

IF you want to keep id instead of name you have to write it out differently. you want to use document.getElementById instead of Request.form

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM