tyooseph Posted September 28, 2007 Share Posted September 28, 2007 Hello, I have a <select> statement which calls a javascipt function, updCities(), upon 'onchange'. My HTML page is generated using php and the javascript is contained within <script> tags at the end of my php script. The function takes the selected value from the <select> statement and populates the <options> of other <select> statements on the same page. The function works fine as long as the javascript script is placed with <script> tags at the end of my php script. But, if I place the javascript script in an external file (.js) I get an 'object expected' error at the line containing the 'onchange' call function. I am not familiar with javascript. I did not generate the code below and need help understanding how to call an external function. How can I call an external javascript function? Does the name of the external file have to be the name of the function? How can I pass the value from the select statement to the external function? Does the <script> tags have to be within the <head> tags?? Thanks, and here's my script... //php document generating the HTML page ... <select name="county" id="county" size=1 onchange="updCities(); "> ... <script language="JavaScript" type="text/javascript" scr="www.arb.ca.gov/msprog/bus/rptg/js/droplists.js"></script> // droplists.js JavaScript Document var url = "getcities.php?county="; // passes value to php script that populates other select options ... function updCities() { if (!isWorking && http) { var county = document.getElementById('county').value; http.open("GET", url + escape(county), true); http.onreadystatechange = handleHttpResponse; isWorking = true; http.send(null); } } Quote Link to comment Share on other sites More sharing options...
Stickybomb Posted September 28, 2007 Share Posted September 28, 2007 ??? sounds like its not creating the xml object for some reason. however i understand little to nothing about what you are trying to do. so you have two drop menus with one controlling the content of the other? the way its worded it sounds like you want to change the contents of the selecet menu onchange which makes nosense and would serve no logical reason. can you provide a link to what you are attempting to do. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.