Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > problem setting hidden field value

Reply
Thread Tools

problem setting hidden field value

 
 
PJ6
Guest
Posts: n/a
 
      11-30-2005
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();
}


 
Reply With Quote
 
 
 
 
Rob Meade
Guest
Posts: n/a
 
      11-30-2005
"PJ6" wrote ....

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


 
Reply With Quote
 
 
 
 
Bruce Barker
Guest
Posts: n/a
 
      11-30-2005
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" <(E-Mail Removed)> wrote in message
news:e0$(E-Mail Removed)...
> 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();
> }
>
>



 
Reply With Quote
 
PJ6
Guest
Posts: n/a
 
      11-30-2005
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" <(E-Mail Removed)> wrote in message
news:%234%(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:e0$(E-Mail Removed)...
>> 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();
>> }
>>
>>

>
>



 
Reply With Quote
 
PJ6
Guest
Posts: n/a
 
      11-30-2005
I got it. Foudn a server-side, now it works a treat.

Thanks,
Paul

"PJ6" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>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" <(E-Mail Removed)> wrote in message
> news:%234%(E-Mail Removed)...
>> 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" <(E-Mail Removed)> wrote in message
>> news:e0$(E-Mail Removed)...
>>> 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();
>>> }
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
javascript validation for a not required field, field is onlyrequired if another field has a value jr Javascript 3 07-08-2010 10:33 AM
Populate Hidden field on post back and retrieve value from Hidden Field Rick ASP .Net 3 04-13-2010 05:38 PM
Select box value changes value of hidden field dvwool@ix.netcom.com Javascript 6 04-27-2006 04:38 AM
Pass hidden form field value to another form field to insert in db GavMc ASP General 4 09-22-2005 06:33 PM
Setting a value to a hidden field Jim Javascript 1 06-09-2004 10:35 PM



Advertisments