Ajax - Complete text fields with data from MySQL according to value from Select box
Posted: 15 Jan 2015, 09:18
I have a Select box and options with IDs of the rows from a MySQL table.
In that form there are 3 text fields.
Now, when I select an option from the Select-box, I want to complete those 3 text fields with data from MySQL according to the ID of the selected option, without reloading the page.
This is the form with the Select-box and the text fields.
Now, I think I have to use JavaScript / Ajax to get data from php and add it in text fields without reloading the page.
Any ideea or example?
In that form there are 3 text fields.
Now, when I select an option from the Select-box, I want to complete those 3 text fields with data from MySQL according to the ID of the selected option, without reloading the page.
This is the form with the Select-box and the text fields.
Code: Select all
<form action="script.php" method="post">
<select id="sel" name="sel">
<option value="1">ID 1</option>
<option value="2">ID 2</option>
<option value="3">ID 3</option>
</select>
<input type="text" name="title" id="title" size="50" />
<input type="text" name="descript" id="descript" size="50" />
<textarea name="content" id="content" rows="7" cols="52"></textarea>
<input type="submit" value="Send" />
</form>
Any ideea or example?