Auto select text field

Overzicht Reageren

Sponsored by: Vacatures door Monsterboard

Bjorn cornelissen

bjorn cornelissen

11/04/2012 10:45:33
Quote Anchor link
Hallo,

Ik heb problemen met het automatisch selecteren van een text veld als de pagina laad.

Heb verschillende Jquery's of Java Scripts gebruikt maar Bij geen 1 een goed resultaat.
Misschien kunne jullie een tutorial aanraden of Mij helpen.

Dit is het veld dat ik wil automatisch selecteren.


Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
<?
            <td colspan='4' align='left'><font color=white>$lang->findItem:</font>
            <
input type='text' size='8' name='item_search'>
            <
input type='submit' value='zoek' tabindex='3'> <a href='delete.php?action=item_search'><font size='-1' color='white'>[$lang->clearSearch]</font></a></td></tr>";
    
    
?>


Groetjes
Gewijzigd op 11/04/2012 10:53:14 door Bjorn cornelissen
 
PHP hulp

PHP hulp

24/11/2024 02:47:04
 
Joakim Broden

Joakim Broden

11/04/2012 10:47:38
Quote Anchor link
Welk veld? Ik zie geen veld..
 
Bjorn cornelissen

bjorn cornelissen

11/04/2012 10:50:38
Quote Anchor link
Nu staat er de goede foutje
 
Joakim Broden

Joakim Broden

11/04/2012 10:54:10
Quote Anchor link
$('input[name="item_search"]').focus(); als je jQuery gebruikt
 
Bjorn cornelissen

bjorn cornelissen

11/04/2012 10:54:42
Quote Anchor link
zal het proberen !
 
Gerhard l

gerhard l

11/04/2012 10:56:12
Quote Anchor link
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
<script language="JavaScript">
<!--

document.the_form_u_use.item_search.focus();

//-->
</script>
 
Bjorn cornelissen

bjorn cornelissen

11/04/2012 10:59:38
Quote Anchor link
gerhard i heb geen form

Toevoeging op 11/04/2012 11:02:09:

Hertog Waar moet ik het neerzetten dan?
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?
[code]<?
    $display
->displayTitle("$lang->newSale1");
    echo "<center><form name='additem' method='POST' action='sale_ui.php'>    
         <table border=0 cellspacing='0' cellpadding='2' bgcolor='$table_bg'>"
;
        

      
          if(isset($_POST['item_search'])  and $_POST['item_search']!='')
          {

              $search=$_POST['item_search'];
              $_SESSION['current_item_search']=$search;
            $query="SELECT p.products_id,p.products_quantity,p.products_model,pd.products_name,p.products_price,tr.tax_rate
            FROM products as p,products_description as pd,tax_rates as tr,tax_class as tc
            WHERE p.products_id=pd.products_id and
            p.products_tax_class_id=tc.tax_class_id and
            tr.tax_class_id=tc.tax_class_id and
            p.products_model like \"%$search%\"  
            and pd.language_id=1
            ORDER by pd.products_name"
;          }
          elseif(isset($_SESSION['current_item_search']))
          {

              $search=$_SESSION['current_item_search'];
            $query="SELECT p.products_id,p.products_quantity,p.products_model,pd.products_name,p.products_price,tr.tax_rate
            FROM products as p,products_description as pd,tax_rates as tr,tax_class as tc
            WHERE p.products_id=pd.products_id and
            p.products_tax_class_id=tc.tax_class_id and
            tr.tax_class_id=tc.tax_class_id and
            p.products_model like \"%$search%\"  
            and pd.language_id=1
            ORDER by products_description.products_name"
;

          }

          else
          {
              $query="SELECT p.products_id,p.products_model,pd.products_name,p.products_price,tr.tax_rate
            FROM products as p,products_description as pd,tax_rates as tr,tax_class as tc
            WHERE p.products_id=pd.products_id and
            p.products_tax_class_id=tc.tax_class_id and
            tr.tax_class_id=tc.tax_class_id and pd.language_id=1 ORDER by pd.products_name"
;
            
          }

          
          
              
              $item_result=mysql_query($query,$dbf_osc->conn);

            $item_title=isset($_SESSION['current_item_search']) ? "<b><font color=white>$lang->selectItem</font></b>":"<font color=white>$lang->selectItem</font>";
            echo "<tr>
            
    <td colspan='4' align='left'><font color=white>$lang->findItem:</font>
           <input type='text' name='item_search'>
    <input type='submit' value='Zoek' tabindex='3'> <a href='index.php'><font size='-1' color='white'>[$lang->clearSearch]</font></a></td></tr>"
;
    ?>
 
Joakim Broden

Joakim Broden

11/04/2012 11:12:06
Quote Anchor link
Bjorn je zegt dat je geen form hebt? Maar wat betekend die <form> tag op regel 4 volgens jou dan?

En javascript zet je in je head van je pagina..
 
Bjorn cornelissen

bjorn cornelissen

11/04/2012 11:15:37
Quote Anchor link
Oh joh ik zie het helemaal over het hoofd omdat het gesplitst staat

heb het er nu neer gezet krijg geen errors of iets maar selecteerd hem niet

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
<?
<head>
<
script language="JavaScript">
<!--


document.additem.item_search.focus();

//-->
</script>

</head>
?>
Gewijzigd op 11/04/2012 11:19:32 door bjorn cornelissen
 
Victor -

Victor -

11/04/2012 12:10:45
Quote Anchor link
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
<?
    <td colspan='4' align='left'><font color=white>$lang->findItem:</font>
    <
input type='text' size='8' name='item_search' autofocus='autofocus'>
    <
input type='submit' value='zoek' tabindex='3'> <a href='delete.php?action=item_search'><font size='-1' color='white'>[$lang->clearSearch]</font></a></td></tr>";
?>
 
Bjorn cornelissen

bjorn cornelissen

11/04/2012 12:28:47
Quote Anchor link
Helaas Werkt niet victor

Andere suggesties?
Gewijzigd op 11/04/2012 12:54:32 door bjorn cornelissen
 
Gerhard l

gerhard l

11/04/2012 12:58:41
Quote Anchor link
Die van Victor en mij werken hier gewoon, die van Hertog Jan niet getest... maar volgens mij doe jij eerder wat fout.
 
Bjorn cornelissen

bjorn cornelissen

11/04/2012 13:16:54
Quote Anchor link
Ik heb Exact gedaan wat er staat hij doet niet het veld selecteren dat je erin kan typen zonder het aan te klikken dus.

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<?
[code]<?php session_start();  ?>

<html>
<head>
<script language="JavaScript">
<!--

document.additem.item_search.focus();

//-->
</script>
</head>

<body>
<?php
include ("../classes/db_functions.php");
include ("../classes/security_functions.php");
include ("../classes/display.php");
include ("../settings.php");
include ("../language/$cfg_language");

$lang=new language();
$dbf=new db_functions($cfg_server,$cfg_username,$cfg_password,$cfg_database,$cfg_tableprefix,$cfg_theme,$lang);
$dbf_osc=new db_functions($cfg_osc_server,$cfg_osc_username,$cfg_osc_password,$cfg_osc_database,'',$cfg_theme,$lang);
$sec=new security_functions($dbf,'Sales Clerk',$lang);
$display=new display($dbf->conn,$dbf_osc->conn,$cfg_theme,$cfg_currency_symbol,$lang);
$table_bg=$display->sale_bg;
$items_table="$cfg_tableprefix".'items';

if(!$sec->isLoggedIn())
{

    header ("location: ../login.php");
    exit();
}


//updating row for an item already in sale.
if(isset($_GET['update_item']))
{

    
    $k=$_GET['update_item'];
    $new_price=$_POST["price$k"];
    $new_tax=$_POST["tax$k"];
    $new_quantity=$_POST["quantity$k"];
    
    $item_info=explode(' ',$_SESSION['items_in_sale'][$k]);
    $item_id=$item_info[0];
    
    $_SESSION['items_in_sale'][$k]=$item_id.' '.$new_price.' '.$new_tax.' '.$new_quantity;


}

    if(isset($_POST['addToCart']))
    {

            
        if(empty($_POST['items']))
        {

            echo "<b>$lang->youMustSelectAtLeastOneItem</b><br>";
            echo "<a href='sale_ui.php'>$lang->refreshAndTryAgain</a>";
            exit();
    
        }

    

    
        $items_to_add=array();
        $items_to_add=$_POST['items'];
        $quantity_to_add=$_POST['quantity'];
    
        for($k=0;$k<count($items_to_add);$k++)
        {

            $_SESSION['items_in_sale'][]=$items_to_add[$k].' '.$quantity_to_add;
        
        }
    
    
    }
    
    ?>

    
<tr>
<td>
    <?
    $display
->displayTitle("$lang->newSale1");
    echo "<center><form name='additem' method='POST' action='sale_ui.php'>    
         <table border=0 cellspacing='0' cellpadding='2' bgcolor='$table_bg'>"
;
        

      
          if(isset($_POST['item_search'])  and $_POST['item_search']!='')
          {

              $search=$_POST['item_search'];
              $_SESSION['current_item_search']=$search;
            $query="SELECT p.products_id,p.products_quantity,p.products_model,pd.products_name,p.products_price,tr.tax_rate
            FROM products as p,products_description as pd,tax_rates as tr,tax_class as tc
            WHERE p.products_id=pd.products_id and
            p.products_tax_class_id=tc.tax_class_id and
            tr.tax_class_id=tc.tax_class_id and
            p.products_model like \"%$search%\"  
            and pd.language_id=1
            ORDER by pd.products_name"
;          }
          elseif(isset($_SESSION['current_item_search']))
          {

              $search=$_SESSION['current_item_search'];
            $query="SELECT p.products_id,p.products_quantity,p.products_model,pd.products_name,p.products_price,tr.tax_rate
            FROM products as p,products_description as pd,tax_rates as tr,tax_class as tc
            WHERE p.products_id=pd.products_id and
            p.products_tax_class_id=tc.tax_class_id and
            tr.tax_class_id=tc.tax_class_id and
            p.products_model like \"%$search%\"  
            and pd.language_id=1
            ORDER by products_description.products_name"
;

          }

          else
          {
              $query="SELECT p.products_id,p.products_model,pd.products_name,p.products_price,tr.tax_rate
            FROM products as p,products_description as pd,tax_rates as tr,tax_class as tc
            WHERE p.products_id=pd.products_id and
            p.products_tax_class_id=tc.tax_class_id and
            tr.tax_class_id=tc.tax_class_id and pd.language_id=1 ORDER by pd.products_name"
;
            
          }

          
          
              
              $item_result=mysql_query($query,$dbf_osc->conn);

            $item_title=isset($_SESSION['current_item_search']) ? "<b><font color=white>$lang->selectItem</font></b>":"<font color=white>$lang->selectItem</font>";
            echo "<tr>
            
 <td colspan='4' align='left'><font color=white>$lang->findItem:</font>
    <input type='text' size='8' name='item_search' autofocus='autofocus'>
    <input type='submit' value='zoek' tabindex='3'> <a href='delete.php?action=item_search'><font size='-1' color='white'>[$lang->clearSearch]</font></a></td></tr>"
;

?>
Gewijzigd op 11/04/2012 13:18:26 door bjorn cornelissen
 



Overzicht Reageren

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.