I want to submit search term ( e.g what does foo means) into form if there is not result
Details:
I have a search function with if else condition where if there is search result than display else message with “No search result found”
Where I wan to change “No search result found” with one form submission where value will be whatever search term user try to find. so…
if search result found {
//display result
} else {
// auto submit below form if above condition is not true ( means if no search result found )
<form action="to url" method="post">
<input name="title" type="text" />
</form>
}
Above is the form which I use to submit form.
EDIT:
Here is the actual code
.......
if (count($results))
$qa_content['title']=qa_lang_html_sub('main/results_for_x', qa_html($inquery));
else { ?>
<form id="nosearch" method="POST" action="<?php echo qa_opt('site_url'); ?>ask" class="top-askbox" >
<input name="title" type="text" value="<?php echo $inquery; ?>">
</form>
<script>$("#nosearch").submit();</script>
<?php }
.......
this is the part where I am working. Actual file is too long.
You can use something like this