Results 1 to 6 of 6

Thread: change select BOX to Input Box

  1. #1

    Thread Starter
    Member
    Join Date
    May 2006
    Posts
    39

    change select BOX to Input Box

    Below part of code of .

    Below codes shows drop down/select box, when option is selected it is redirected to the url.

    What i would like to do is i like input box instead drop down/select box. USer can enter title ( option of dropdown/select box) manually.

    PHP Code:

    $query 
    "SELECT j.* FROM #__weblinks j inner join #__categories jc on j.catid = jc.id where $cat  j.published='1' AND jc.published='1' ORDER BY $orderStr";
            
    $db->setquery($query);
            
    $rows=$db->loadObjectList();
            
    error_reporting(E_ERROR); 
            
    $url $_SERVER['SERVER_URI'];
        
            echo 
    "<form action='" $url "' method='post' >";
            

                echo 
    "<select style='display:none'  name='add' id='add'";
                if (
    $autodirect == 1
                    {
                         echo 
    " onChange='this.form.elements";
                         echo 
    "[\"submit\"].click();' />";
                    }
                else
                {
                    echo 
    " />";
                }        
            if (
    $blank == '1')
                echo 
    "<option value='' />";
            if (
    $custom != '')
            {
                echo 
    "<option value='' />".$custom;
                if (
    $separator != '')
                    echo 
    "<option value='' />".str_repeat($separator,strlen($custom));
            }

            foreach (
    $rows as $row)
            {
                echo 
    "<option value='" .$row->url"' /> "$row->title;
            }
            echo 
    "</select>"
    Any Help will be highly appreciated..

    Ramesh chaudhary

  2. #2
    Junior Member
    Join Date
    Aug 2009
    Location
    Australia, Melbourne
    Posts
    29

    Re: change select BOX to Input Box

    Code:
    <input type="text" name="myInputBox" />
    That's all you need to add, it isn't quite clear what this form is doing so ill let you do it yourself but yea that's pretty much and input box just not sure where you need it added.

  3. #3

    Thread Starter
    Member
    Join Date
    May 2006
    Posts
    39

    Re: change select BOX to Input Box

    Quote Originally Posted by SharpCode View Post
    Code:
    <input type="text" name="myInputBox" />
    That's all you need to add, it isn't quite clear what this form is doing so ill let you do it yourself but yea that's pretty much and input box just not sure where you need it added.
    Thank you very much Sharp Code

    <input type="text" name="myInputBox" /> will not work.

    Below is complete php code.

    I only want to input box instead select box, where title can be entered manually instead selecting from drop down option.




    PHP Code:

    <?php
        defined
    ('_JEXEC') or die ('Direct Access is not allowed');
        
    $allweblinks intval($params->get('allweblinks',0));
        
    $golabel $params->get('buttonname','Go');
        
    $blank intval($params->get('firstblank',0));
        
    $custom $params->get('firsttext','');
        
    $separator $params->get('separator','');
        
    $image $params->get('buttonimage','-1');
        
    $catname strtolower($params->get('catname','jumplinks'));
        
    $autodirect intval($params->get('autodirect',0));
        if (isset(
    $_POST['submit']) || isset($_POST['submit_x']))
        {
            
    $link $_POST['add'];
            
    $target $params->get('target','parent');
            switch (
    $target)
            {
            
            case 
    'parent':
                echo 
    "<meta http-equiv='Refresh' content='0;URL=" .$link"' />";
                break;
            case 
    'newwith':
                echo 
    "<meta http-equiv='Refresh' content='0;URL=" .$_SERVER["PHP_SELF"]. "' />";
                echo 
    "<script type='text/javascript'>window.open('".$link."');</script>";
                break;
            case 
    'newwithout':
                echo 
    "<meta http-equiv='Refresh' content='0;URL=" .$_SERVER["PHP_SELF"]. "' />";
                echo 
    "<script type='text/javascript'>window.open('".$link."','',config='toolbar=no');</script>";
                break;
            
            
            }
            exit();
        }
        
            
    $db JFactory::getDBO();
            
    $cat "lower(jc.title) = '".$catname."' AND ";
            if (
    $allweblinks == '1')
                
    $cat '';
            
    $order $params->get('order',0);
            
            switch (
    $order)
            {
                case 
    0:
                    
    $orderStr "ordering";
                    break;
                case 
    1:
                    
    $orderStr "j.title ASC";
                    break;
                case 
    2:
                    
    $orderStr "j.title DESC";
            }
            
    $query "SELECT j.* FROM #__weblinks j inner join #__categories jc on j.catid = jc.id where $cat  j.published='1' AND jc.published='1' ORDER BY $orderStr";
            
    $db->setquery($query);
            
    $rows=$db->loadObjectList();
            
    error_reporting(E_ERROR); 
            
    $url $_SERVER['SERVER_URI'];
        
            echo 
    "<form action='" $url "' method='post' >";
            

                echo 
    "<select style='display:none'  name='add' id='add'";
                if (
    $autodirect == 1
                    {
                         echo 
    " onChange='this.form.elements";
                         echo 
    "[\"submit\"].click();' />";
                    }
                else
                {
                    echo 
    " />";
                }        
            if (
    $blank == '1')
                echo 
    "<option value='' />";
            if (
    $custom != '')
            {
                echo 
    "<option value='' />".$custom;
                if (
    $separator != '')
                    echo 
    "<option value='' />".str_repeat($separator,strlen($custom));
            }

            foreach (
    $rows as $row)
            {
                echo 
    "<option value='" .$row->url"' /> "$row->title;
            }
            echo 
    "</select>";
           
                if (
    $autodirect == 1)
                {
                    
    $style="style='visibility:hidden'";
                }
                if (
    $image !=-)
                {
                    if (
    $autodirect ==1)
                        echo 
    "<input type='submit' ".$style." id='submit' name='submit' value='".$golabel."' />";
                    
    $image 'images/stories/'.$image;
                    echo 
    "<input type='image' " .$style." src='".$image."' id='submit' name='submit' alt='".$golabel."' />";
                }
                else
                {
                    
                    echo 
    "<input type='submit' ".$style." id='submit' name='submit' value='".$golabel."' />";
                }


            echo  
    "</form>";
        
     
    ?>

  4. #4

    Thread Starter
    Member
    Join Date
    May 2006
    Posts
    39

    Re: change select BOX to Input Box

    Still my problem is not solved. Is there somebody who can help me out ....

  5. #5
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: change select BOX to Input Box

    Quote Originally Posted by RameshChaudhary View Post
    Still my problem is not solved. Is there somebody who can help me out ....
    What do you mean it doesn't work? The code "Sharp Code" gave you is the correct code for an input box.
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  6. #6
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: change select BOX to Input Box

    Your problem can be solved very simply.

    1. Stop using echo to output HTML. PHP is designed to be embedded in HTML, not vice versa. Your code is virtually unreadable.

    2. Read this web page:
    http://w3schools.com/html/html_forms.asp

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width