Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

AJAX Help

Status
Not open for further replies.

ggggus

Programmer
Jul 5, 2003
114
I'm trying to set up what I thought would be a simple ajax system, but I'm having troulbe with javascript returned to the client.

here's the relevant code:
Code:
<script src="/js/ajax.js" type="TEXT/JAVASCRIPT"></script>
<div id="div_find_model"></div>
<script language="JavaScript" type="text/javascript">
<!--
find_model();
//-->
</script>

and what is being returned to fill that div with: document.getElementById('div_find_model').innerHTML = http.responseText;
is the following:
Code:
<select name="brand_id" style="width: 120" class="form_select" onChange="find_model(this.value);">
<option value=0>Select Brand</option>
<option ....>a list of options here</option>
</select>
[\code]

Ok, so here is what happens, The first code executes properly, but once an item is selected from the drop down, it is not executing find_model() again. The javascrip console in Firefox is telling me that find_model is not a function. It is a function, and it executes properly when it is called from outside of the div.

How do I fix this?

***************************************
J. Jacobs
[URL unfurl="true"]http://www.piercedmedia.com[/URL]
 
find_model is defined in src="/js/ajax.js" and the function works fine.
When called it does all the ajax stuff that loads the content into <div id="div_find_model"></div>.

It works perfectly fine in the first block of code above...but when I try to call the function again from the returned code (to relaod the ajax div) it does not work.

***************************************
J. Jacobs
 
I found the problem. apparently javascript looks at the whole page. Code that I didn't include on here is the form code.

the form code was
Code:
<form method="post" action="/equipment" name="find_model">

The form was named the same as the javascript function, changing the name of either fixes the problem.

***************************************
J. Jacobs
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top