-1

I am trying to resubmit my webpage through javascript based on the results of a change to a drop down menu. The drop down menu is created through an SQL query.

HTML/PHP

<td> Workorder/IO: <select id = "WOIODD" name="WO/IO" onchange="getVal()">
<?php
foreach($WoIo as $workorder)
  {
    echo '<option>'.$workorder.'</option>';
  }
?>
</select>
</td>
</tr>
<?php $currentWo=($_GET['cwo']); ?>

JAVASCRIPT

 function getVal()
    {
        var currentVal = document.getElementById('WOIODD').value;
        location.href="?cwo="+currentVal;
    }

The problem is document.getElementById.value is returning nothing. The value IS NOT null, but nothing is being returned. When I tried to fix the javascript, alert(currentVal) displayed a blank box, even after it was run conditionally with no null value. I need to be able to run another query based on the option chosen in the Work Order dropdown menu.

Any ideas on why this happening, how to fix, or even an alternative method all together?

Thank you, Joshua

Vikas Yadav
  • 3,094
  • 2
  • 20
  • 21
Joshua Averbuch
  • 97
  • 1
  • 11

1 Answers1

0

Problem was solved. First the java script was change to

 function getVal(dropdown)
{
    var currentVal = dropdown.value;

    location.href="?cwo="+currentVal;
}

Then the HTML/PHP was changed to

<td> Workorder/IO: <select id = "WOIODD" name="WO/IO" onchange="getVal(this)">
<?php
foreach($WoIo as $workorder)
   {
  echo '<option value="'.$workorder.'">'.$workorder.'</option>';
  }
 ?>

Basically it was NOT assessing each option the value so I explicitly assessed each value.

Thank you to everyone's comments it helped point me in the right direction

Joshua Averbuch
  • 97
  • 1
  • 11