Results 1 to 2 of 2

Thread: populate drop down list and textfield

  1. #1
    Join Date
    Sep 2006
    Posts
    30
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default populate drop down list and textfield

    hello there,

    i need help from anyone who could help me to solve this problem. i have a drop down that had a list from the database. which means that i list down the data from the database. i need to populate a textfield based on the user selection from the drop down list.

    i had a code which can do the work,but the problem is the selection from the drop down list will not be stored into a database. only the value from the textfield will be stored...
    can anyone help me to slve this problem??

    //javascript function

    <script language='javascript'>
    function move(s)
    {
    document.form1.grpval.value = s;
    }
    </script>

    //database
    mysql_select_db('customs', $dbConn);
    $query = "SELECT * FROM address WHERE name <> add1 <> add2 <> add3";
    $Recordset1 = mysql_query($query) or die(mysql_error());
    $row_Recordset1 = mysql_fetch_assoc($Recordset1);
    $totalRows_Recordset1 = mysql_num_rows($Recordset1);

    mysql_select_db('customs', $dbConn);
    $query2 = "SELECT add1,add2,add3 FROM address WHERE add1 <> name";
    $Recordset2 = mysql_query($query2) or die(mysql_error());
    $row_Recordset2 = mysql_fetch_assoc($Recordset2);
    $totalRows_Recordset2 = mysql_num_rows($Recordset2);

    //drop down
    <select name="description" onChange="move(this.value);" id = "description">
    <?php
    do {
    ?>
    <option value="<?php echo $row_Recordset3['grpval']?>"><?php echo $row_Recordset3['description']?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $row_Recordset3['amount']?></option>
    <?php
    } while ($row_Recordset3 = mysql_fetch_assoc($Recordset3));
    $rows = mysql_num_rows($Recordset3);
    if($rows > 0) {
    mysql_data_seek($Recordset3, 0);
    $row_Recordset3 = mysql_fetch_assoc($Recordset3);
    }
    ?>
    </select>

    //textfield
    <input name="grpval" type="text" class="style3" id="grpval" size="10" readonly>

  2. #2
    Join Date
    Nov 2006
    Posts
    42
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    If you could write your question more clearly & understandably maybe someone could help.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •