Q: Automatically select a value in one row when a certain value is given in another row, how? Is there any way an option in one row can automatically be selected if a value in another row is given a certain value?
In my example, let's say if "price1" is price1 is selected, then course1 will automatically selected, and if course2 is selected, then price2 will automatically be selected. Is there perhaps another way to go around this, to make it more simple? I'm using Dreamweaver CS4
Thank you
<form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
  <table>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Price:</td>
      <td><label>
        <select name="price" id="price">
          <option value="price1">price1</option>
          <option value="price2">price2</option>
        </select>
      </label></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Course:</td>
      <td><label>
        <select name="course" id="course">
          <option value="course1">course1</option>
          <option value="course2">course2</option>
        </select>
      </label></td>
    </tr>
  </table>
</form>


A: You can do this with javascript like this...
var pr = document.getElementById("price");
var co = document.getElementById("course");

pr.onchange = function() {
  if(this.value == "price1")
  {
      co.selectedIndex = 0;
  }
    if(this.value == "price2")
  {
      co.selectedIndex = 1;
  }
}

co.onchange = function() {
  if(this.value == "course1")
  {
      pr.selectedIndex = 0;
  }
    if(this.value == "course2")
  {
      pr.selectedIndex = 1;
  }
}

