-3

I have made an hidden html field <input type="hidden" name="t" id="t" value="something">

<? // value here?>

How I can get this value with out submitting the page

hakre
  • 193,403
  • 52
  • 435
  • 836
Muhammad Usman
  • 10,426
  • 22
  • 72
  • 107
  • I dont understand. if this input is being created server side you should already have the value there. If you are trying to get it off a client side created input box youll need to post it back to the server – Undefined May 30 '12 at 13:00
  • this filed is created from the response of an request from external server – Muhammad Usman May 30 '12 at 13:01
  • probably author looks somethind like javascript document.getElementById('t').value – heximal May 30 '12 at 13:02
  • 1
    You already have the value. In your example, the value is `something`. When you build that field in the page response, whatever value you use to set that is the value of the field. If it came from a database, you have it in the database. If it came from session state, you have it in session state. Etc. What, exactly, are you trying to accomplish here? – David May 30 '12 at 13:06
  • Response, but by whom? Is code related? If so, please post it. Your question is just totally not clear what you would like to know, there are many ways to obtain that value (as it's already there). – hakre May 30 '12 at 13:28

2 Answers2

3

How I can get this value with out submitting the page

You can't get its value in PHP without submitting your from, use JavaScript instead to get its value.

Example:

alert(document.getElementById('t').value);
Sarfraz
  • 377,238
  • 77
  • 533
  • 578
2

You can't. PHP is server side. This means, PHP's job is finished as soon the page finished loading.

You could send the form value to your PHP script with AJAX, which would be in the background - no submitting or refreshing needed.

Edit: Did you mean to ask, how you can get the value for your hidden input after the page was generated?

Ahatius
  • 4,777
  • 11
  • 49
  • 79