Cannot call a javascript function using dynamically generated html?
<p>I'm writing a simple search engine script using HTML/JS/Ajax/PHP and generating results dynamically from within the PHP script.  The search process begins with a JS function called from an onclick() event.  I'd like to embed a button into my search results that would call the original JS function, but with a new value to search for.  Here's what I mean:</p>

<pre><code>(foo     )  [first search button]

info
more info [new search]

info
more info [new search]

info
more info [new search]
</code></pre>

<p>The first line would be a text box where the user searches for 'foo'; then all the other lines (below) would be generated based on that search.  I'd like for the user to be able to follow up on particular search results by hitting its respective [new search] button, which would run the original JS function, passing in the 'more info' value as a new search criteria.</p>

<p>This doesn't seem to be working, however.  All I'm getting from the JS console when I hit the [new search] button is 'unexpected number' and 'unexpected identifier'.  Is what I'm trying to do conceivably possible or does something about ajax content prevent this from working in the first place?</p>

<p>Here's the dynamically generated line that calls the JS function:</p>

<pre><code>print '&lt;input type="button" value="search" onclick="doSearch('. $searchValue . ')"&gt;';
</code></pre>

<p>I'm not sure what else to share that would be helpful, since there are several hundred lines over two files.  If you'd like to see more, please let me know.</p>
