I am trying to rewrite the W3C AJAX Livesearch script to echo a <button> instead of an <a>, which seems to be printing but the inline Javascript isn't responding to the AJAX script. Here is the PHP I've modified.
$hint="<button='type' class='mybutton' name='users' value='" .
$z->item(0)->childNodes->item(0)->nodeValue . "' onclick='showUser(this.value)'>" .
$y->item(0)->childNodes->item(0)->nodeValue . "</button>";
I modified the the XML nodes to just contain a title and a value (1-n). The request seems to be working but it looks like the is not receiving a value. I have a feeling it is something to do with the way I've coded the PHP. Any thoughts? Thanks in advance!
EDIT: Problem answered, it was a simple syntax error in the markup. I took out my live example link, but refer to the W3C link if you are interested in learning the script. Good stuff!
The problem is the HTML you provide in the dynamically loaded content, which looks like this (from inspecting the given link):
<button='type' class="mybutton" name="users" value="1"
onclick="showUser(this.value)">Peter Griffin </button>
this.value returns undefined as you can see in this fiddle because this is no valid HTML syntax. You need to provide a proper button like the following:
<button class="mybutton" name="users" value="1"
onclick="showUser(this.value)">Peter Griffin </button>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With