Jump to content

PHP Issue - Getting PHP Information into a Text Box


KevinB

Recommended Posts

I'm a beginner when it comes to PHP and am currently developing a website which I need a little bit of help with. It's mostly done and working etc... but there are a few small issues I would like to iron out.

 

I have attached a screenshot below and the code for the table and the switch statement to make the problem a little clearer.

 

phpproblem.th.jpg

 

As you can see the program is working fine and printing to the screen but its printing to the bottom left rather than to the 'total' text box within the table. The table is written in html and the output box on the bottom left is written in php and only executes within a case statement.

 

Table:

<form method="post" action="/my.php" class="contactForm">
<table width="194" border="1" align="center">
  <tr>
    <td width="67"><span class="style1">Hours:</span></td>
    <td width="150"><input name="hours" type="text" onFocus=" class="inputWidth" size = '12' value="
"/></td>
  </tr>
  <tr>
    <td><span class="style1">Minutes:</span></td>
    <td><input name="minutes" type="text" class="inputWidth" size = '12' value="
"/></td>
  </tr>
  <tr>
    <td><span class="style1">Seconds:</span></td>
    <td><input name="seconds" type="text" class="inputWidth" size = '12' value="
"/></td>
  </tr>
  <tr>
    <td><span class="style1">Format:</span></td>
    <td><select name="format">
      <option value="kb">Kilobytes</option>
      <option value="mb">Megabytes</option>
      <option selected value="gb">Gigabytes</option>
      <option value="tb">Terabytes</option>
    </select></td>
  </tr>
  <tr>
    <td><span class="style1"><b>Total:</b></span></td>
    <td><input name="total" type="text" disabled onFocus="blur();" class="inputWidth" size = '12' value= " "/></td>
  </tr>

</table>
<p align="center">
  <input type="submit" name="submit" value="Calculate"/>
  <input type="reset" name="reset" onclick="cleartext()" value="Clear"/>
</p>
<p> </p>
<p> </p>
<br />
</form>

 

 

else
{
switch ($format)
{
case kb:
  print("<td> <input type ='text' disabled value ='$kilobytes' size = '10'> </td>");
  break; 
case mb:
  print("<td> <input type ='text' disabled value ='$megabytes' size = '10'> </td>");
  break;
case gb:
  print("<td> <input type ='text' disabled value ='$gigabytes' size = '10'> </td>");
  break;
case tb:
  print("<td> <input type ='text' disabled value ='$terabytes' size = '10'> </td>");
  break;
default:
  echo "Error";
}

 

 

I just need to get the output from the switch to print in the text box called 'total' which is in the HTML table. Any help would be muchly appreciated.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.