Board index » Web Programming » Form variables missing - tried googling, but still not working

Form variables missing - tried googling, but still not working

Web Programming257
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


-
 

Re:Form variables missing - tried googling, but still not working

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









<jethro_uk@hotmail.com>wrote in message

Quote
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







-

Re:Form variables missing - tried googling, but still not working

jethro_uk@hotmail.com wrote:

Quote
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>







--

Microsoft MVP -- ASP/ASP.NET

Please reply to the newsgroup. The email account listed in my From

header is my spam trap, so I don't check it very often. You will get a

quicker response by posting to the newsgroup.





-

Re:Form variables missing - tried googling, but still not working



Bob Barrows [MVP] wrote:

Quote
jethro_uk@hotmail.com wrote:

>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>

>.

>.



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



Quote
>.

>

>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>







--

Microsoft MVP -- ASP/ASP.NET

Please reply to the newsgroup. The email account listed in my From

header is my spam trap, so I don't check it very often. You will get a

quicker response by posting to the newsgroup.



-