Form variables missing - tried googling, but still not working

J

jethro_uk

Hi there,

I have a bizarre problem with FORM variables in ASP.

Scenario using VI6, IE6, Windows2000 server:

MyPage.ASP:
..
..
..
<FORM method=POST action=Process.ASP id=frmDetails>
<INPUT name=txtName id=txtName type=text>
<INPUT name=txtAddress id=txtName type=text>
</FORM>
..
..
..

If this form is submitted, then i can inspect Request.Form in the
debugger, and both variables are there.

Now, I have a 3rd form, which is called by a "javascript:window.open"
call, with txtName.value as a parameter. This form queries a database,
and presents a list of possible addresses to match "name". When one is
selected, it goes :
..
..
..
window.opener.txtAddress.value=<value>
..
..
..

however, when MyPage.ASP is then submuitted, txtAddress doesn't get
sent across.

I have tried using method=GET to inspect the URL, but txtAddress is not
being passed.

Intercepting the submit, and doing an "alert(txtAddress.value)" shows
that txtAddress is correctly populated (I knew it was anyway, since I
can see it's contents on the page), however, the
"Request.FOrm("txtAddress") is returning nothing.

Can anyone help, I have tried googling, but found nothing specific to
my problem.

thanks in advance

J
 
B

Bob Barrows [MVP]

Hi there,

I have a bizarre problem with FORM variables in ASP.

Scenario using VI6, IE6, Windows2000 server:

MyPage.ASP:
.
.
.
<FORM method=POST action=Process.ASP id=frmDetails>
<INPUT name=txtName id=txtName type=text>
<INPUT name=txtAddress id=txtName type=text>
</FORM>
.
.
.

If this form is submitted, then i can inspect Request.Form in the
debugger, and both variables are there.

Now, I have a 3rd form, which is called by a "javascript:window.open"
call, with txtName.value as a parameter. This form queries a database,
and presents a list of possible addresses to match "name". When one is
selected, it goes :
.
.
.
window.opener.txtAddress.value=<value>
.
.
.

however, when MyPage.ASP is then submuitted, txtAddress doesn't get
sent across.

I have tried using method=GET to inspect the URL, but txtAddress is
not being passed.

Intercepting the submit, and doing an "alert(txtAddress.value)" shows
that txtAddress is correctly populated (I knew it was anyway, since I
can see it's contents on the page), however, the
"Request.FOrm("txtAddress") is returning nothing.

Can anyone help, I have tried googling, but found nothing specific to
my problem.

thanks in advance

J

Seems to work fine for me. here is how I tested it:

<%@ Language=VBScript %>
<%
for each key in Request.Form
Response.Write key & ": """ & Request.Form(key) & """<BR>"
next
%>
<html><body>
<FORM method=POST action="" id=frmDetails>
<INPUT name=txtName id=txtName type=text>
<INPUT name=txtAddress id=txtName type=text>
<INPUT type="submit" value="Submit" id=submit1 name=submit1>
</FORM>
<INPUT type="button" value="Button" id=button1 name=button1
onclick="window.open('setaddress.htm')">
</body></html>

setaddress.htm:
<HTML>
<BODY>

<INPUT type="button" value="Button" id=button1 name=button1
onclick="test();" >
<SCRIPT LANGUAGE=javascript>
function test()
{
window.opener.frmDetails.txtAddress.value='test';
window.close();
}
</SCRIPT>
</BODY>

</HTML>
 
M

Michael Kujawa

I do not use Both name and ID attributes
I just use one, the name attribute

I would imagine what is happening is the txtName id
for address is holding the value as it is the last text input id in
the form.

Both Name and Address share the same ID
 
J

jethro_uk

Problem solved. And I am so annoyed I missed it, since it nearly killed
me 18 months ago !

I left out one line of code in my cut down example. The one which went
:

txtAddress.disabled=true.

disabled controls are not POSTed !!!!!

Thanks for your replies all
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,534
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top