I want my textbox and textarea to be import base on selected value, for example, on my select box, there are options subject A and subject B, when I choose subject B, the textbox will automatically insert subject B and the textarea will import the preset message which is stored in database.
Currently I have success imported message by selected option, how can I insert subject to textbox as well when I click button?
JQuery:
$(document).ready(function() {
$("#copyBtn").click(function(){
$("#selmessage").val($("#selectBox").val());
});
});
PHP:
<input type="Text" name="seltitle" value="<?=$the_title;?>">
<select id="selectBox" name="seltitle2">
<option selected></option>
<?php
$q = "SELECT * FROM template ORDER BY preset_subj ASC";
$result = $mysqli->query($q) or die($mysqli->error);
while($row = $result->fetch_array(MYSQLI_BOTH)){
?>
<option value="<?php echo $row['message'] ?>"><?php echo $row['preset_subj']; } ?></option>
</select>
<input id="copyBtn" type="button" value="import to message" />
<textarea name="selmessage" id="selmessage"></textarea>