Hi

First of all my apologies if this is the wrong forum. I managed to get this to work when I wanted a dynamic drop down to adjust the values in a second drop down and fill in a text value in a text box.

Now I want to cut out the second step: ie. I actually want to get rid of the second drop down and simply enter a value in the text box. I have tried everything to remove the second step but as soon as I do everything stops working.

At the moment the function looks at the second drop down and sets the options for it and I added the line

document.getElementById('fld_ClientID').value ="<?=$m['ClientID'];?>"

to get it to enter the data in the text box. How do I now get it to look at the text box only.



The code is as follows:

PHP Code:
<?php 
$mysql_link 
mysql_connect("localhost","blah","Sugar") or die ("can't connect to mysql"); 
$mysql_select mysql_select_db("Figure",$mysql_link) or die ("can't select db"); 
?> 

<html> 
<head> 
<title>Enter Winners</title> 
<script language="javascript"> 
function setOptions(chosen) { 
  var selbox = document.myform.selectpromotion;
  
  selbox.options.length = 0; 
  if (chosen == "0") { 
    selbox.options[selbox.options.length] = new Option('First select a client','0'); 
    
  } 
  <?php 
  $client_result 
mysql_query("SELECT * FROM tblClients ORDER BY ClientName") or die(mysql_error()); 
  while(@(
$c=mysql_fetch_array($client_result))) 
  { 
  
?> 
    if (chosen == "<?=$c['ClientID'];?>") { 
     
    <?php 
    $c_id 
$c['ClientID']; 
    
$promo_result mysql_query("SELECT * FROM tblPromotions WHERE ClientID='$c_id'") or die(mysql_error()); 
    while(@(
$m=mysql_fetch_array($promo_result))) 
    { 
    
?> 
      selbox.options[selbox.options.length] = new 
      Option('<?=$m['PromotionName'];?>','<?=$m['ClientID'];?>');
      document.getElementById('fld_ClientID').value ="<?=$m['ClientID'];?>";
    <?php 
    

    
?> 
    } 
  <?php 
  

  
?> 

</script> 
</head> 
<body> 
<form name="myform"  method="POST" action="processaddpromotionNEW.php"> ><div align="center"> 
  <p>
     <select name="selectclient" size="1" 
    onchange="setOptions(document.myform.selectclient.options 
    [document.myform.selectclient.selectedIndex].value);"> 
    <option value="0" selected>Select a client</option> 
    <?php 
    $result 
mysql_query("SELECT * FROM tblClients ORDER BY ClientName") or die(mysql_error()); 
        while(@(
$r=mysql_fetch_array($result))) 
    { 
    
?> 
    <option value="<?=$r['ClientID'];?>">
      <?=$r['ClientName'];?>
      </option> 
    <?php 
    

    
?> 
  </select>
  <br><br> 
  <select name="selectpromotion" size="1"> 
    <option value=" " selected>First select a client</option> 
  </select>
  </p>
  <p>
<input name="fld_ClientID" type="text" class="Arial" id="fld_ClientID" tabindex="11" size="10" />
  <br>
    <br> 
    <input type="button" name="go" value="Value Selected" 
onclick="alert(document.myform.selectpromotion.options 
[document.myform.selectpromotion.selectedIndex].value);">
  </p>
</div></form> 
</body> 
</html>