Here's what I have so far:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript" src="/js/jquery.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#weight").change(onSelectChange);
});
function onSelectChange(){
var selected = $('#weight').val();
$.post("tship.php", {weight: selected},
function(data){
$("#ship").html(data.ret_html);
}, "json");
}
</script>
</head>
<body>
<select id="weight">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
</select>
<br />
<div id="ship">
</div>
</body>
</html>
I want to change it so that onSelectChange accepts a single parameter. I need to be able to call the function for other events as well - not only when the select box value changes. Here is my attempt, not working:
<script type="text/javascript">
$(document).ready(function() {
$("#weight").change(onSelectChange($('#weight').val()));
});
function onSelectChange(parm){
$.post("tship.php", {weight: parm},
function(data){
$("#ship").html(data.ret_password);
}, "json");
}
</script>