How do you insert values into hidden fields?

Discussion in 'JavaScript' started by Imozeb, Feb 23, 2010.

  1. #1
    I want to insert values into hidden fields so I can post them to PHP. How would I do this?

    And...
    Is this the best way because some people say hidden fields are easy to hack.
     
    Imozeb, Feb 23, 2010 IP
  2. aquilax

    aquilax Member

    Messages:
    126
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    33
    #2
    Try this:
    <input type="hidden" name="hidden_field" value="whatever" />
    Code (markup):
    Keep in mind that the field is just not visible for the common user. This doesn't mean that it cannot be modified.
     
    aquilax, Feb 23, 2010 IP
  3. Stomme poes

    Stomme poes Peon

    Messages:
    3,195
    Likes Received:
    136
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Anyone can just open their text editor and change the values to whatever they want. Pretty much anything sitting on the front-end (HTML, CSS, JS, etc) can be manipulated as it's easily accessed. So your PHP will have to double-check those values to make sure they are correct and make sense.
     
    Stomme poes, Feb 24, 2010 IP