I am basically a newbie with javascript. I want to populate a div in my webpage from a select form found on the same page, when the user selects the book and chapter he wants to view and presses the submit button. Here the code:
<script type="text/javascript" charset="utf-8">
var setArray = newArray(
bk1, 001, "this is my chapter content for the <div>",
bk1, 002, "this is my chapter content for the <div>",
bk1, 003, "this is my chapter content for the <div>",
bk2, 001, "this is my chapter content for the <div>",
bk2, 002, "this is my chapter content for the <div>"
etc....
);
</script>
<form>
<select id="book">
<option value="">Select Book</option>
<option value="bk1">Book 1</option>
<option value="bk2">Book 2</option>
<option value="bk3">Book 3</option>
</select>
<select id="chapter">
<option value="">Select Chapter</option>
<option value="001">1</option>
<option value="002">2</option>
<option value="003">3</option>
</select>
<button id="button" type="submit">View</button>
</form>
<div id="content">
I want the content from the js array for the selected book and chapter to be placed here without reloading the page.
</div>
Note: I have simplified the code to make it a little easier to follow. I am sure my js array is incorrect and needs fixing for my purpose. Also, I don't want the page to refresh, only the div to update. Thanks for any help.