0

I am trying to collect the index of my combo box. I would like to be able to change the index, and then have a bunch of fields changed based on the new index. Am I doing this right so far?

Thanks.

<script type="text/javascript">
     function getCombo(sel) {
     var value = sel.options[sel.selectedIndex]; 
     $.get(document, {type: value}); 
}
</script>

// Misc code here

<td class="bold"><label for='addType'>Select Type to Add : </label>
    <select name="addType" id="combo" onchange="getCombo(this)">
        <option value="book">Book</option>
        <option value="author">Author</option>
        <option value ="publisher">Publisher</option>
        <option value="customer">Customer</option>
    </select>
<?php
    $type['type'] = $_GET['value'];
?></td>
4

1 回答 1

1

如果我了解您的问题,请尝试以下代码:

 <script type="text/javascript">
      $("#combo").change(function(){
           var value = $(this).val();
           $.get(document, {type: value});
      });
 </script>

 <td class="bold"><label for='addType'>Select Type to Add : </label>
    <select name="addType" id="combo" >
       <option value="book">Book</option>
       <option value="author">Author</option>
       <option value ="publisher">Publisher</option>
       <option value="customer">Customer</option>
    </select>
<?php
    $type['type'] = $_GET['type']; // beacuse 
?>
</td>
于 2012-04-30T16:04:03.423 回答