rcorrigal Posted April 21, 2009 Share Posted April 21, 2009 Why can’t I get this to work? Any hints? It's for an input tag in an html form. Thanks! <?php $value=currentField.value; if ( $value < "3" ) echo "border: 1px red solid;"; ?> Link to comment https://forums.phpfreaks.com/topic/155096-conditional-formatting/ Share on other sites More sharing options...
rondog Posted April 21, 2009 Share Posted April 21, 2009 it may be 3 not "3" Link to comment https://forums.phpfreaks.com/topic/155096-conditional-formatting/#findComment-815831 Share on other sites More sharing options...
soak Posted April 21, 2009 Share Posted April 21, 2009 Wouldn't matter if it was 3 or "3" Whats currentField.value ? that looks like javascript. Link to comment https://forums.phpfreaks.com/topic/155096-conditional-formatting/#findComment-815833 Share on other sites More sharing options...
kenrbnsn Posted April 21, 2009 Share Posted April 21, 2009 It looks like you're trying to mix Javascript and PHP. Please explain what you are trying to do. Ken Link to comment https://forums.phpfreaks.com/topic/155096-conditional-formatting/#findComment-815834 Share on other sites More sharing options...
rcorrigal Posted April 21, 2009 Author Share Posted April 21, 2009 Your right I was mixing javascript and php by mistake. However, how do I pass the field value to $value for the if statement? I am trying to make a field highlight if it's under a certain number. Link to comment https://forums.phpfreaks.com/topic/155096-conditional-formatting/#findComment-815856 Share on other sites More sharing options...
soak Posted April 21, 2009 Share Posted April 21, 2009 I don't think you need to unless you're populating it in javascript. Can you show us a bit more code please? Link to comment https://forums.phpfreaks.com/topic/155096-conditional-formatting/#findComment-815859 Share on other sites More sharing options...
rcorrigal Posted April 21, 2009 Author Share Posted April 21, 2009 Hope this helps... <input value="<?echo mysql_result(mysql_db_query($db_name, "SELECT p1G6 FROM Students WHERE teacherid='$data[login]' AND ID=0 "),0);?>" name="p1G6" id="p1G6" type="text" onblur="this.value=eedisplayFloat(eeparseFloat(this.value));recalc_onclick('p1G6')" onkeyup="testform(this)" maxlength="1" tabindex="4" style=' width:100%; <?php if ( currentField.value < 3 ) { echo "border: 1px red solid;"; }; ?> ' class='ee142'> Link to comment https://forums.phpfreaks.com/topic/155096-conditional-formatting/#findComment-815869 Share on other sites More sharing options...
soak Posted April 21, 2009 Share Posted April 21, 2009 <?php $fieldValue = mysql_result(mysql_db_query($db_name, "SELECT p1G6 FROM Students WHERE teacherid='$data[login]' AND ID=0 "),0); ?> <input value="<?= $fieldValue ?>" name="p1G6" id="p1G6" type="text" onblur="this.value=eedisplayFloat(eeparseFloat(this.value));recalc_onclick('p1G6')" onkeyup="testform(this)" maxlength="1" tabindex="4" style=' width:100%; <?php if ( $fieldValue < 3 ) { echo "border: 1px red solid;"; }; ?> ' class='ee142'> Link to comment https://forums.phpfreaks.com/topic/155096-conditional-formatting/#findComment-815872 Share on other sites More sharing options...
rcorrigal Posted April 21, 2009 Author Share Posted April 21, 2009 Sweet thanks! ** That works great, however not very efficient for about 100 fields. Link to comment https://forums.phpfreaks.com/topic/155096-conditional-formatting/#findComment-815879 Share on other sites More sharing options...
soak Posted April 21, 2009 Share Posted April 21, 2009 Select all of your fields in one go and loop through them. See mysql_fetch_assoc Link to comment https://forums.phpfreaks.com/topic/155096-conditional-formatting/#findComment-815889 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.