Since I could not explain the question posted sometime earlier, Here is a another try. All i want is to have the value of a current option that is selected, so that i can echo that value inside the input field's value. 

### JavaScript

```
function id() {
    var sel = document.getElementById("cate");
    // to get the value of the selected option
    var selectedid = sel.options[sel.selectedIndex].value;
    return selectedid;
}

```

### PHP

```
<form action="" method="POST">
    <select name="cate">
    <?php 
        $que1 = "SELECT * FROM category";
        $res1 = mysql_query($que1);
        while($row = mysql_fetch_array($res1)) {    
            $cat_id_db = $row['cat_id'];                 
            $cat_db = $row['cat_name'];                  
    ?>

        <option value="<?php echo $cat_id_db; ?>" >
            <?php echo $cat_db;?>
        </option>

    <? } ?>
    </select>

    <p><label class="field">Category ID:</label></p>

    //HERE!
    <input type="text" name="cat_id"  value="<?php echo $cat_id_db; ?>" class="textbox-300" pattern="[a-zA-Z0-9\. ]+" title="Please enter your Item Price">
</form>

```

`//HERE!`: this is the place where i want to use the value of the current/selected option instead of the php code written.