$('#DOM').onchange('URL');
method but could not get it to work either.
I know I should use a php file and a javascript but I have done both on the same page until I finish the development and then i switch them.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Baby Names</title>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<!-- stop the web browser from ever caching this page or its images -->
<meta http-equiv="Cache-Control" content="no-cache" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />
<!-- instructor-provided CSS stylesheet and favicon; do not modify -->
<link href="names.css" type="text/css" rel="stylesheet" />
<!-- instructor-provided Javascript files; do not modify -->
<script src="http://ajax.googleapis.com/ajax/libs/prototype/1.6.1.0/prototype.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/scriptaculous/1.8.3/scriptaculous.js" type="text/javascript"></script>
<!-- your file -->
<!--<script src="names.js" type="text/javascript"></script>-->
<script>
window.onload = function()
{
<?= $names = file("http://isat-cit.marshall.edu/babynames.php?type=list"); ?>;
$("babyselect").onchange = namePicked;
};
function namePicked(myForm)
{
var ajax = new XMLHttpRequest();
ajax.open("GET", "nameMeaning.txt", "false");
ajax.send(null);
$("meaning").value = ajax.responseText;
alert(ajax.responseText);
//var selectedIndex = myForm.babyselect.selectedIndex;
//var selectedName = myForm.babyselect.options[selectedIndex].text;
//var nameMeaning1 = "http://isat-cit.marshall.edu/babynames.php?type=meaning&name=";
//var nameMeaning2 = nameMeaning1+ selectedName;
//$('#meaning').load('nameMeaning2');
//alert(nameMeaning2);
}
</script>
</head>
<body>
<h1>Baby Names Redux</h1>
<fieldset id="namearea">
<legend>Name:</legend>
<!-- list of baby names-->
<form name='myform'>
<select name="babyselect" id="babyselect" onchange="namePicked(this.form)">
<option value="">Select a name...</option>
<?php
foreach ($names as $nameValue => $name)
{
print '<option value="'.$nameValue.'">'.$name.'</option>';
}
?>
</select>
</form>
</fieldset>
<!-- baby ranking data should be graphed into the div below -->
<div id="graph">
</div>
<fieldset id="meaningarea">
<legend>Origin/Meaning:</legend>
<!-- baby name meaning data should be inserted into the paragraph below -->
<p id="meaning">
</p>
</fieldset>
<!-- an empty div for inserting any error text -->
<div id="errors"></div>
</body>
</html>
This post has been edited by Atli: 24 November 2011 - 09:07 AM
Reason for edit:: Added the attached code into the post. It's easier for everybody if you just post your code, rather than attach it.

New Topic/Question
Reply


MultiQuote





|