Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // in your HTML:
- <form>
- <select name="staff"> onchange="cs50Info(this.value);">
- <option value ="">Select someone:</opntion>
- <option value="blumberg">Hannah Blumberg</option>
- <option value="bowden">Rob Bowden</option>
- </select>
- </form>
- // in your JS file:
- function CS50Info(name)
- {
- // deal with the situation where nothing is chosen
- if (name == "")
- return;
- // create a new AJAX object
- var ajax = new XMLHttpRequest();
- // when the page is loaded, have a callback function pre-fill our div
- ajax.onreadystatechange = function() {
- if (ajax.readyState == 4 && ajax.status == 200)
- $('#infodiv').html(ajax.responseText);
- }
- };
- // open the requested file and transmit the data
- ajax.open("GET", name + '.html', true);
- ajax.send();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement