Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Jun 2006
    Location
    Lancaster, PA
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    passing variable to a hidden form field

    ok. i just need to know the syntax to send a variable to a hidden form field from within a function. i know it's simple, but my brain is fried already this week. thank you!

    the field's name is "sendItems" and the form's name is "sampleform".
    Last edited by the noobinator; 06-29-2006 at 05:35 PM.

  • #2
    Senior Coder angst's Avatar
    Join Date
    Apr 2004
    Location
    Toronto, Ontario
    Posts
    2,114
    Thanks
    15
    Thanked 122 Times in 122 Posts
    try:
    document.FormName.FieldName = "SomeValue"


    -Ken

  • #3
    New to the CF scene
    Join Date
    Jun 2006
    Location
    Lancaster, PA
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    so it would be:

    return document.formName.fieldName = "myVar"
    ?

  • #4
    New to the CF scene
    Join Date
    Jun 2006
    Location
    Lancaster, PA
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    anyone?

  • #5
    Senior Coder
    Join Date
    Jul 2005
    Location
    New York, NY
    Posts
    1,084
    Thanks
    4
    Thanked 19 Times in 19 Posts
    why would you need to return anything? The statement document.formname.fieldname.value = "somevalue" assigns the text "somevalue" to the value of the field "fieldname" that sits in the form "formname"

    No need for a return.

  • #6
    New Coder
    Join Date
    Jun 2006
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    rather do this

    document.getElementById("FieldName").value = "something"

    You'll need to give your hidden field an id, but this is better for cross-browser support.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •