KevinB Posted March 24, 2009 Share Posted March 24, 2009 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. 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. Link to comment https://forums.phpfreaks.com/topic/150928-php-issue-getting-php-information-into-a-text-box/ Share on other sites More sharing options...
KevinB Posted March 24, 2009 Author Share Posted March 24, 2009 Any help? I still cannot figure this out and it's the last step to completing my application. Link to comment https://forums.phpfreaks.com/topic/150928-php-issue-getting-php-information-into-a-text-box/#findComment-793153 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.