problem setting hidden field value

Discussion in 'ASP .Net' started by PJ6, Nov 30, 2005.

  1. PJ6

    PJ6 Guest

    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();
    }
    PJ6, Nov 30, 2005
    #1
    1. Advertising

  2. PJ6

    Rob Meade Guest

    "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.
    Rob Meade, Nov 30, 2005
    #2
    1. Advertising

  3. PJ6

    Bruce Barker Guest

    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" <> wrote in message
    news:e0$...
    > 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();
    > }
    >
    >
    Bruce Barker, Nov 30, 2005
    #3
  4. PJ6

    PJ6 Guest

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

    >
    >
    PJ6, Nov 30, 2005
    #4
  5. PJ6

    PJ6 Guest

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

    Thanks,
    Paul

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

    >>
    >>

    >
    >
    PJ6, Nov 30, 2005
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rick
    Replies:
    3
    Views:
    8,149
    Alexey Smirnov
    Apr 13, 2010
  2. GavMc
    Replies:
    4
    Views:
    325
    Evertjan.
    Sep 22, 2005
  3. Jim

    Setting a value to a hidden field

    Jim, Jun 9, 2004, in forum: Javascript
    Replies:
    1
    Views:
    98
  4. Replies:
    6
    Views:
    206
  5. jr
    Replies:
    3
    Views:
    418
Loading...

Share This Page