Paul Paul - 1 year ago 89
Javascript Question

Problems with getElementById with jquery load

I have a page, showlist.php, which loads a set of results from a recordset. There is a search field which returns results using jquery load. This works fine for one word, but not if there is more than one word in the search query. Can anybody show how to get this to work for any search query? Must be some basic error but googling around has not helped.

Key elements of showlist.php:-

<div id="contentarea">

<script type="text/javascript">
function contentloader(url){

<input name="search" type="text" id="inputsearch"/>

<a onclick="contentloader('showlist.php?search='+document.getElementById('inputsearch').value+'')">Search</a>


Answer Source

You need to HTML encode the result of document.getElementById('inputsearch').value so that all the works are passes to the server.


HTML-encoding in JavaScript/jQuery

Encode URL in JavaScript?

and links therein.