problem setting hidden field value

  • Thread starter Thread starter PJ6
  • Start date Start date
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();
}
 
....
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.
 
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)
 
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();
}
 
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();
}
 
Back
Top