I'm trying to get the value of a dropdown then inserting it to my textboxes then after that it will save to database. The data is coming from the database. The problem is after I select data from the dropdown then click the insert button; only one textbox has changed. The other row is not changing. And when I click on insert button of the 2nd row, it changes the 1st row textbox.
javascript
- function copyValue(id) {
- var dropboxvalue = document.getElementById('mydropbox').value;
- document.getElementById('mytextbox').value = dropboxvalue;
- }
home.php
- <td align="center"><input type="submit" name="insert" onclick="copyValue(<?php echo $r['so_id'] ?>)" class="btn btn-success" value="Insert" /></td>
- <td><input class="form-control" name="dar_numberr" id="mytextbox" type="text" required="required" placeholder="Delivery Date" value="<?php echo $r['dar_numberr'] ?>"></textarea></td>
dropdown
- <?php
- $databaseHost = "localhost";
- $databaseUser = "root";
- $databasePassword = "";
- $databaseName = "csl_otd";
-
- $con=mysql_connect($databaseHost ,$databaseUser ,$databasePassword )or die ('Connection Error');
- mysql_select_db("csl_otd",$con) or die ('Database Error');
- ?>
- <select name="dar_number" id="mydropbox" class="form-control">
- <option value=""> -----------Available DAR Number----------- </option>
- <?php
- $dd_res=mysql_query("Select DISTINCT dar_number from dar");
- while($r=mysql_fetch_row($dd_res))
- {
- echo "<option value='$r[0]'> $r[0] </option>";
- }
- ?>
- </select>