By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.

    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

JavaScript Combined two Search Forms - not functioning


Bronze Coder
Thanks for all the previous help. The web script that I’m modifying has a Search Form that successfully appears when a particular type of page displays:

<?php if (preg_match('#/?sub__(\d)+\b#',$_SERVER['REQUEST_URI'],$matches)) {
echo "<form action='#' method='POST' id='sub_id'>
<input name='search_sub'>
<input type='submit' value='search' />
<input type='hidden' value='{$matches[1]}'> </form>";
} ?>

I wanted to enhance the Form’s appearance and tested this HTML Search Form (which slides the text enter field across the page upon selecting the magnify glass icon) seperately successfully:

<div id="sb-search" class="sb-search " >
        <input class="sb-search-input " onkeyup="buttonUp();" placeholder="Enter your search term..." onblur="monkey();" type="search" value="" name="search" id="search">
        <input class="sb-search-submit" type="submit"  value="">
        <span class="sb-icon-search"><i class="fa fa-search"></i></span>

the HTML Search Form has this corresponding js:

function buttonUp(){
         var valux = $('.sb-search-input').val();
            valux = $.trim(valux).length;
            if(valux !== 0){
            } else{

        var submitIcon = $('.sb-icon-search');
        var submitInput = $('.sb-search-input');
        var searchBox = $('.sb-search');
        var isOpen = false;

            if(isOpen == true){

            return false;

            return false;

            if(isOpen == false){
                isOpen = true;
            } else {
                isOpen = false;

I’ve combined the two Search form codes successfully like so:

if (preg_match('#/?sub__(\d)+\b#',$_SERVER['REQUEST_URI'],$matches)) {
echo "<form action='#' method='POST' id='sub_id'>
<input class='sb-search-input ' onkeyup='buttonUp();' placeholder='Enter your search term...' onblur='monkey();' type='search' value='' name='search_sub' id='search'>
<!--<input name='search_sub'>-->
<input class='sb-search-submit' type='submit' value=''>
<span class='sb-icon-search'><i class='fa fa-search'></i></span>
<!--<input type='submit' value='search' />-->
<input type='hidden' value='{$matches[1]}'>

however, now the search Form does not slide the text enter field across the page, it is just already 'open' when the page displays.

I’m looking for help with getting the text enter field to slide across the page upon selecting the magnify glass icon again, instead of it being open (when the page displays).

If that makes sense I look forward to any assistance.

New Threads

Latest posts

Buy us a coffee!

Top Bottom