Page 1 of 1

Google Chrome issue with POST variables in hidden fields

Posted: Fri May 22, 2009 11:33 am
by quiksilver02x
So I'm trying to do something very basic here: pass a variable via POST to another page, and echo that variable in a subsequent hidden field. I made a generic example:

page #1

Code: Select all

<body><form id="form1" name="form1" method="post" action="aa.php">
  <label>
  <input type="text" name="box1" id="box1" />
  </label>
  <label>
  <input type="submit" name="submit" id="submit" value="Submit" />
  </label>
</form>
</body>
page #2

Code: Select all

<body><form id="form1" name="form1" method="post" action="">
 Display passed variable: <?php echo $_POST["box1"]; ?><br />
<input name="take_box1" type="hidden" id="take_box1" value="<?php echo $_POST["box1"]; ?>" />
</form>
</body>
The variable will display when the echo statement is placed outside the hidden field, but will NOT display inside the hidden field.

I am only having this problem with Google Chrome. I'm about to lose my mind. Any ideas?

Re: Google Chrome issue with POST variables in hidden fields

Posted: Fri May 22, 2009 11:50 am
by Christopher
quiksilver02x wrote:The variable will display when the echo statement is placed outside the hidden field, but will NOT display inside the hidden field.

I am only having this problem with Google Chrome. I'm about to lose my mind. Any ideas?
You need to do both if you want the value both displayed and passed. The field type is called "hidden" because it is not displayed, but is passed with the form.

Re: Google Chrome issue with POST variables in hidden fields

Posted: Fri May 22, 2009 3:19 pm
by quiksilver02x
but why does it work with all browsers but chrome?

Re: Google Chrome issue with POST variables in hidden fields

Posted: Fri May 22, 2009 3:24 pm
by Christopher
If you view source, what exactly does the hidden field look like?

Also, why no <html></html> tags?