Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <h1>How to add an IxQuick Search Box inside form tags "nested" in your asp.net form tags, complete with submit function.</h1> <p>Salve! I had a similar problem. I had an aspx page built on a master page which contained the asp.net form tag. Now, I wanted an Ixquick searchbox on that page, but I needed to enclose it inside of form tags to make it work; but, of course, you can't have nested form tags in the aspx page.</p> <h2>Here is how I solved my problem:</h2> <p>I created the entire searchbox in jquery and added it to the aspx page by using jquery to replace an empty div. Javascript runs in the client <em>after</em> the server serves up its code, thereby bypassing any issue with nested divs. This also avoids any issue with the master page's submit behaviour for the master page's form tag. You get your own form tag in the outputted html, and your own submit behaviour.</p> <p>Put these two lines in your aspx page where you want your search box to appear.</p> <pre><code>&lt;div id="search"&gt;&lt;/div&gt; &lt;script type="text/javascript"&gt;AddSearchBox("#search");&lt;/script&gt; </code></pre> <p>And in my .js file, I added:</p> <pre><code>function AddSearchBox(where){ var SearchingForm = "&lt;form id='metasearch' name='metasearch' method='POST' accept-charset=' UTF-8' action='javascript:SearchBarSubmit()' &gt;&lt;input name='keyword' type='text' size='32' id='searchbox' /&gt;&lt;input type='submit' value='WebSearch' id='searchbutton' /&gt;&lt;/form&gt; " $(where).html(SearchingForm); return false; } function SearchBarSubmit(){ var searchquery = $('#searchbox').val(); location.href="http://ixquick.com/do/metasearch.pl?query=" + searchquery + "&amp;cat=web&amp;language=english&amp;cmd=process_search&amp;frm=sb&amp;linkback_url=http://www.mywebsite.com&amp;linkback_sitename=mySiteName"; return false; } </code></pre> <p>Now, whenever someone types into my searchbox, it automatically runs the searchquery in IxQuick and displays the results - just like it would in a normal html form. And what's better, if they don't have javascript turned on, they don't get a broken searchbox, because they get no searchbox at all! I don't mind that, because I am adding the searchbox for the sake of being nifty.</p> <p>If you use this code, make sure to change "www.mywebsite.com" to your own website, and make sure to change the linkback of "mySiteName" to your website's name.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload