title: How do I display data on a text field upon selection of an option in a form
body: <p>I have been trying to update a field. Bid price and offer price are the fields I want to update. The selections are gbp/usd, eur/usd, etc. I would like to define the text field with variables like <code>$bid</code>, <code>$bid1</code>, <code>bid2</code>, etc. which are already predefined. Can someone help me with this?</p>
  
  <p>This is my code.</p>
  
  <pre class="lang-php prettyprint-override"><code>&lt;?php
  $timestamp=time();set_time_limit (0);
  
  ?&gt;
  
  &lt;!DOCTYPE html&gt;
  &lt;head&gt;&lt;/head&gt;
  &lt;body&gt;
  &lt;meta charset="UTF-8"&gt;
  
  &lt;form action ="price.php" method="post"&gt;
  
  
  &lt;p&gt;Symbol : &lt;select name="currency_pair"&gt;
  &lt;option value="gbp/usd"&gt;GBP/USD&lt;/option&gt;
  &lt;option value="eur/usd"&gt;EUR/USD&lt;/option&gt;
  &lt;option value="usd/cad"&gt;USD/CAD&lt;/option&gt;
  &lt;option value="usd/chf"&gt;USD/CHF&lt;/option&gt;
  &lt;option value="usd/jpy"&gt;USD/JPY&lt;/option&gt;
  &lt;option value="eur/chf"&gt;EUR/CHF&lt;/option&gt;
  &lt;option value="eur/jpy"&gt;EUR/JPY&lt;/option&gt;
  &lt;option value="aud/usd"&gt;AUD/USD&lt;/option&gt;
  
  &lt;/select&gt;&lt;/p&gt;
  &lt;p&gt; Date : &lt;input type="datetime" value="&lt;?php echo date("Y-m-d ",$timestamp); ?&gt;" name="date"/&gt;    &lt;/p&gt;
  &lt;p&gt; Type : &lt;input type="radio" name="type" value="buy"&gt;Buy 
  &lt;input type="radio" name="type" value="sell"&gt;Sell
  &lt;p&gt; Size : &lt;input type="number"pattern="[0-9]+([\.|,][0-9]+)?" step="0.01"name="size"/&gt;&lt;/p&gt;
  &lt;p&gt; Bid Price : &lt;input type="number" step="any" readonly name="entry" value="&lt;?php if  ($currency_pair=="gbp/usd"){echo bid;}elseif($currency_pair=="eur/usd"){echo bid2;};?&gt;" &gt;
  Offer Price&lt;input type="number" step="any" readonly="yes" name="entry" value="&lt;?php if ($currency_pair=="gbp/usd"){echo bid;}elseif($currency_pair=="eur/usd"){echo bid2;};?&gt;" &gt;&lt;/p&gt;
  &lt;p&gt; Stop Loss : &lt;input type="number"step="any" name="stoploss"/&gt;&lt;/p&gt;
  &lt;p&gt; Take Profit : &lt;input type="number"step="any"name="takeprofit"/&gt;&lt;/p&gt;
  
  &lt;input type="submit" value="Submit"/&gt;
  &lt;/form&gt;
  &lt;script&gt;
  &lt;/script&gt;   &lt;/body&gt; &lt;/html&gt;
  </code></pre>