ihatephp Posted October 30, 2008 Share Posted October 30, 2008 Eg: loan calulator There is a text box to key in the loan amt, interest rate,and loan period. after inputing the values, say if it is worthy to take this loan, there will be a text box highlighted green.If it's not worthy,this box will be highlighted Red. How should i go about doing this Link to comment https://forums.phpfreaks.com/topic/130693-highlighted-box/ Share on other sites More sharing options...
MasterACE14 Posted October 30, 2008 Share Posted October 30, 2008 <?php if(isset($_POST['period']) && isset($_POST['interest']) && isset($_POST['loan'])) { // do calculations // if loan is good if() { // display green text box } // if loan is no good else { // display red text box } } else { echo = FORM <form action="thispage.php" method="post"> Loan Period <input type="text" name="period" /> Interest Rate <input type="text" name="interest" /> Loan <input type="text" name="loan" /> <input type="submit" /> </form> FORM; } ?> use that as a starting point Link to comment https://forums.phpfreaks.com/topic/130693-highlighted-box/#findComment-678223 Share on other sites More sharing options...
ihatephp Posted October 30, 2008 Author Share Posted October 30, 2008 I have done the starting part already ,including the calculation. I'm just stuck at the part where the box is to turn green/red upon a certain result. Link to comment https://forums.phpfreaks.com/topic/130693-highlighted-box/#findComment-678224 Share on other sites More sharing options...
JasonLewis Posted October 30, 2008 Share Posted October 30, 2008 The following will give you an input box with a red border. <input type="text" name="box" id="box" style="border:1px solid #ff0000;"> Link to comment https://forums.phpfreaks.com/topic/130693-highlighted-box/#findComment-678230 Share on other sites More sharing options...
MasterACE14 Posted October 30, 2008 Share Posted October 30, 2008 and use the if and else to determine which box to show the user Link to comment https://forums.phpfreaks.com/topic/130693-highlighted-box/#findComment-678234 Share on other sites More sharing options...
ihatephp Posted October 30, 2008 Author Share Posted October 30, 2008 The following will give you an input box with a red border. <?php if ($amt<=1000){ echo "<big><b>good loan</b></big>"; <input type="text" name="box" id="box" style="border:1px solid #ff0000;">?> So,if i want this GOOD LOAN to be in a red box,(aft the calcluation) how should i rearrange the codes. Link to comment https://forums.phpfreaks.com/topic/130693-highlighted-box/#findComment-678235 Share on other sites More sharing options...
runnerjp Posted October 30, 2008 Share Posted October 30, 2008 <?php if ($amt<=1000){?> <big><b>GOOD loan</b></big> <input type="text" name="box" id="box" style="border:1px solid #00ff00;"> <?php } else { ?> <big><b>BAD loan</b></big> <input type="text" name="box" id="box" style="border:1px solid #ff0000;"> <?php } ?> that will do it Link to comment https://forums.phpfreaks.com/topic/130693-highlighted-box/#findComment-678263 Share on other sites More sharing options...
runnerjp Posted October 30, 2008 Share Posted October 30, 2008 sorry same code just abit neater lol... teasted and works fine! <?php if ($amt<=1000){ echo '<big><b>GOOD loan</b></big>'; echo ' <input type="text" name="box" id="box" style="border:1px solid #00ff00;">'; } else { echo '<big><b>BAD loan</b></big>'; echo '<input type="text" name="box" id="box" style="border:1px solid #ff0000;">'; } ?> Link to comment https://forums.phpfreaks.com/topic/130693-highlighted-box/#findComment-678269 Share on other sites More sharing options...
ihatephp Posted October 30, 2008 Author Share Posted October 30, 2008 It worked fine! though the words good loan appears outside the red box. instead,i'd want to enhance it to be like this. So, if i have a table with 2 columns , 5 rows,the amount $1000 is good. So the column of $1000 will be lighted red aft the computation. amount $100 amount $1000 ??? Link to comment https://forums.phpfreaks.com/topic/130693-highlighted-box/#findComment-678338 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.