Auto select text field
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)
1
2
3
4
5
6
7
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>";
?>
<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
Welk veld? Ik zie geen veld..
Nu staat er de goede foutje
$('input[name="item_search"]').focus(); als je jQuery gebruikt
zal het proberen !
Toevoeging op 11/04/2012 11:02:09:
Hertog Waar moet ik het neerzetten dan?
Code (php)
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
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>";
?>
[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>";
?>
En javascript zet je in je head van je pagina..
heb het er nu neer gezet krijg geen errors of iets maar selecteerd hem niet
Code (php)
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
<?
<head>
<script language="JavaScript">
<!--
document.additem.item_search.focus();
//-->
</script>
</head>
?>
<head>
<script language="JavaScript">
<!--
document.additem.item_search.focus();
//-->
</script>
</head>
?>
Gewijzigd op 11/04/2012 11:19:32 door bjorn cornelissen
Code (php)
1
2
3
4
5
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>";
?>
<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>";
?>
Die van Victor en mij werken hier gewoon, die van Hertog Jan niet getest... maar volgens mij doe jij eerder wat fout.
Code (php)
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
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>";
?>
[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