problem setting hidden field value

P

PJ6

From a control's onkeypress the below javascript snippet is executed. I am
attmpting to set the value of a hidden field... I believe I'd be able to get
the contents of the hidden field by using
"Page.Request.Item(MyHiddenFieldName)" sever-side, no? Unfortunately the
field doesn't look like it's even being set. Is there something special I
need to do?

TIA,
Paul

----------------------------

if (event.keyCode == 13)
{
event.returnValue=false;
event.cancelBubble = true;
document.forms[0].MyHiddenFieldName.Value='something';
document.forms[0].submit();
}
 
R

Rob Meade

....
From a control's onkeypress the below javascript snippet is executed. I am
attmpting to set the value of a hidden field... I believe I'd be able to
get the contents of the hidden field by using
"Page.Request.Item(MyHiddenFieldName)" sever-side, no?

After the page is submitted, yes, I've always used:

Dim hiddenValue as string

hiddenValue = Request.Form("hiddenFieldName")
Unfortunately the field doesn't look like it's even being set. Is there
something special I need to do?

You could always change the hidden field to a normal text box, just
temporarily, then you would actually "see" if the javascript was setting the
value of the control.
 
B

Bruce Barker

your client script is wrong. javascript is case sensitive you you are
dynamically creating a "Value" property and setting its value. of cource
this is not posted back. try:

document.forms[0].MyHiddenFieldName.value='something';


-- bruce (sqlwork.com)
 
P

PJ6

I changed it as you suggested but the value still isn't being set. :(

The funny thing is, when I remove the hidden field, I get a JavaScript
error, so I know it's being referenced properly. Really wierd.

Paul

Bruce Barker said:
your client script is wrong. javascript is case sensitive you you are
dynamically creating a "Value" property and setting its value. of cource
this is not posted back. try:

document.forms[0].MyHiddenFieldName.value='something';


-- bruce (sqlwork.com)


PJ6 said:
From a control's onkeypress the below javascript snippet is executed. I
am attmpting to set the value of a hidden field... I believe I'd be able
to get the contents of the hidden field by using
"Page.Request.Item(MyHiddenFieldName)" sever-side, no? Unfortunately the
field doesn't look like it's even being set. Is there something special I
need to do?

TIA,
Paul

----------------------------

if (event.keyCode == 13)
{
event.returnValue=false;
event.cancelBubble = true;
document.forms[0].MyHiddenFieldName.Value='something';
document.forms[0].submit();
}
 
P

PJ6

I got it. Foudn a server-side, now it works a treat.

Thanks,
Paul

PJ6 said:
I changed it as you suggested but the value still isn't being set. :(

The funny thing is, when I remove the hidden field, I get a JavaScript
error, so I know it's being referenced properly. Really wierd.

Paul

Bruce Barker said:
your client script is wrong. javascript is case sensitive you you are
dynamically creating a "Value" property and setting its value. of cource
this is not posted back. try:

document.forms[0].MyHiddenFieldName.value='something';


-- bruce (sqlwork.com)


PJ6 said:
From a control's onkeypress the below javascript snippet is executed. I
am attmpting to set the value of a hidden field... I believe I'd be able
to get the contents of the hidden field by using
"Page.Request.Item(MyHiddenFieldName)" sever-side, no? Unfortunately the
field doesn't look like it's even being set. Is there something special
I need to do?

TIA,
Paul

----------------------------

if (event.keyCode == 13)
{
event.returnValue=false;
event.cancelBubble = true;
document.forms[0].MyHiddenFieldName.Value='something';
document.forms[0].submit();
}
 

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

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,123
Latest member
Layne6498
Top