teedo757
asked on
using onchange after ajax call
If I have a page called review.php and on that page the user selects a job and hits submit, it calls an ajax function that gets all the job information from getreviewinfo.php and pastes that info into a div tag on the review.php page.
review.php --> getreviewinfo.php (Gets order information) Ajax
review.php <-- table with order info is passed back
Withing the table is another ajax lookup function to find available items, it is triggered by an onchange="showItem(this.va lue)
This does not work and I am not sure if the onchange will not work since the table was created on the getreview.php page and not the review.php page which is where the user will interact. Any help would be great, thanks
review.php --> getreviewinfo.php (Gets order information) Ajax
review.php <-- table with order info is passed back
Withing the table is another ajax lookup function to find available items, it is triggered by an onchange="showItem(this.va
This does not work and I am not sure if the onchange will not work since the table was created on the getreview.php page and not the review.php page which is where the user will interact. Any help would be great, thanks
I'm wondering if you might get better results by putting the second AJAX lookup function into a separate div and passing back two updates from getreviewinfo. That way the onChange would already be part of the DOM when the page was loaded.
make sure. that showItem function is included in review.php page and not on getreviewinfo.php page...
ASKER
......ya its on the getreviewinfo.php page. Not sure if there is a way to put it on the review.php page.
Is there a some way to keep the ajax session open to look for a change?
Some code:
<!-- this is the drop down
<select name="itemcatsearch" id="category" size="1" onchange="showItem(this.va lue)">
<option value="0" selected="selected" >Please Select Category</option>
<option value="audio" >Audio</option>
<option value="decor">Decor</optio n>
<option value="fx">Fx</option>
<option value="lighting">Lighting< /option>
<option value="power">Power</optio n>
<option value="rigging">Rigging</o ption>
<option value="video">Video</optio n>
</select></td>
<!--Function to call getitem.php to fill the item drop down box -------------------------- ---------- ---------- ---------- ------->
<script type="text/javascript">
function showItem(str)
{
if (str=="")
{
document.getElementById("t xtItem").i nnerHTML=" ";
return;
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.X MLHTTP");
}
xmlhttp.onreadystatechange =function( )
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("t xtItem").i nnerHTML=x mlhttp.res ponseText;
}
}
xmlhttp.open("GET","getite mcus.php?c atagory="+ str,false) ;
xmlhttp.send();
}
</script>
Is there a some way to keep the ajax session open to look for a change?
Some code:
<!-- this is the drop down
<select name="itemcatsearch" id="category" size="1" onchange="showItem(this.va
<option value="0" selected="selected" >Please Select Category</option>
<option value="audio" >Audio</option>
<option value="decor">Decor</optio
<option value="fx">Fx</option>
<option value="lighting">Lighting<
<option value="power">Power</optio
<option value="rigging">Rigging</o
<option value="video">Video</optio
</select></td>
<!--Function to call getitem.php to fill the item drop down box --------------------------
<script type="text/javascript">
function showItem(str)
{
if (str=="")
{
document.getElementById("t
return;
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.X
}
xmlhttp.onreadystatechange
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("t
}
}
xmlhttp.open("GET","getite
xmlhttp.send();
}
</script>
ASKER
Its setup as three drop down boxes.
catagory --> item --> Qty
Then there is an add button that adds the product to the order.
I want the review page to allow any adds to an order so I wanted to include this functionality.
catagory --> item --> Qty
Then there is an add button that adds the product to the order.
I want the review page to allow any adds to an order so I wanted to include this functionality.
ASKER
Ray_Paseur how would I do this?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
in your original getreviewinfo.php, replace :
<script type="text/javascript">
function showItem(str)
by:<script type="text/javascript">
showItem = function(str)
ASKER
leakim971 I tried your fix and it did not seem to do anything. kshna answer did not fix everything but it did make that section work.
thanks for your feedback, have fun and a good week!