I have a page on my site which, when a button is pressed, pulls in an AJAX response in a <div>. The response also has AJAX in it (this all works as it should).
I want to be able to, after several checkboxes are checked, enable a button so that the process on the page can be completed and the workorder updated to "ready for pickup" status. (it's a workorder site and this particular page has several checkboxes on it that, as certain steps in a workflow is done, the user checks which updates the DB).
My problem is that I can't get the simple JS that I'm using to run. What it does is checks to see that ALL of the checkboxes are checked and if so, it enables the "Complete" button.
Now I understand that I can't run JS in an AJAX request directly, but that I need to eval() it or use some other method. Well here's my test (which isn't working).
On the ajax request (which is a database populated form), I've added this at the beginning:
<script type="text/javascript" id="runscript">
alert("This Works!!");
</script>
Then, on the main page which displays the ajax request (in a div), I've added at the end of the page:
<script type="text/javascript">
eval(document.getElementById("runscript").innerHTML);
</script>
(This was per the advice of an ajax expert that I know, but he wasn't specific on everything).
Well I would assume that as soon as I click the button to load the ajax request, an alert will popup saying "This Works!", but it doesn't. Once I get this to work, then I know that I can get the js that I need to use to work as well.
What am i doing wrong, and/or is there a better way to do this?