0

<script>

function calculateText(el) {

var form = el.form;
var idx = form.Selfrating1.selectedIndex;

  if (idx <= 0) {


form.reset();
return;


  }




  if (form.Selfrating1.value == "Good") {


 form.T11.value = "#008000";



  } else if (form.Selfrating1.value == "Satisfactory") {


  form.T11.value = "#9ACD32";



  } else if (form.Selfrating1.value == "Mixed") {


 form.T11.value = "#FFFF00";

} else if (form.Selfrating1.value == "Problematic") {
  form.T11.value = "#FF0000";
}


  }

</script>

<p>a.i.Self Rating(1st Rating): <select name="Selfrating1" onchange="calculateText(this)" value="<?php echo $row['Selfrating1']; ?>">

    <option selected>Please select an option</option>                           


<option value=Good <?php if($row['Selfrating1']=='Good') { echo "selected"; }?>>Good</option>
<option value=Satisfactory <?php if($row['Selfrating1']=='Satisfactory') { echo "selected"; }?>>Satisfactory</option>
<option value=Mixed <?php if($row['Selfrating1']=='Mixed') { echo "selected"; }?>>Mixed</option>
<option value=Problematic <?php if($row['Selfrating1']=='Problematic') { echo "selected"; }?>>Problematic</option>

</select>
<input type="color" name="T11" onchange="calculateText(this)"></p>

2
Contributors
4
Replies
23
Views
2 Years
Discussion Span
Last Post by Sophia_1
0

Wrap your code with form (<form></form>) tag.Like

<form>
<p>a.i.Self Rating(1st Rating): <select name="Selfrating1" onchange="calculateText(this)" value="<?php echo $row['Selfrating1']; ?>">

    <option selected>Please select an option</option>
    <option value=Good <?php if($row['Selfrating1']=='Good') { echo "selected"; }?>>Good</option>
    <option value=Satisfactory <?php if($row['Selfrating1']=='Satisfactory') { echo "selected"; }?>>Satisfactory</option>
    <option value=Mixed <?php if($row['Selfrating1']=='Mixed') { echo "selected"; }?>>Mixed</option>
    <option value=Problematic <?php if($row['Selfrating1']=='Problematic') { echo "selected"; }?>>Problematic</option>

</select>
<input type="color" name="T11" onchange="calculateText(this)"></p>
</form>

Edited by Bachu

0

Hi, tried to put in the form tag but still no change of color for textbox. Please advise. Tq

0

This code is working on my PC.

<script>

    function calculateText(el) {

var form = el.form;
var idx = form.Selfrating1.selectedIndex;

    if (idx <= 0) {
    form.reset();
    return;
    }
    if (form.Selfrating1.value == "Good") {
    form.T11.value = "#008000";
    } else if (form.Selfrating1.value == "Satisfactory") {
    form.T11.value = "#9ACD32";
    } else if (form.Selfrating1.value == "Mixed") {
    form.T11.value = "#FFFF00";
    } else if (form.Selfrating1.value == "Problematic") {
    form.T11.value = "#FF0000";
    }
    }

</script>

<form>
<p>a.i.Self Rating(1st Rating): <select name="Selfrating1" onchange="calculateText(this)">

    <option selected>Please select an option</option>
    <option value="Good" >Good</option>
    <option value="Satisfactory" >Satisfactory</option>
    <option value="Mixed" >Mixed</option>
    <option value="Problematic">Problematic</option>

</select>
<input type="color" name="T11" onchange="calculateText(this)"></p>
</form>

Which browser/Version you are using ?

Edited by Bachu

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.