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;"; ?> Quote Link to comment Share on other sites More sharing options...
rondog Posted April 21, 2009 Share Posted April 21, 2009 it may be 3 not "3" Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment 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? Quote Link to comment 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'> Quote Link to comment 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'> Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.