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.


<?
<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
Die van Victor en mij werken hier gewoon, die van Hertog Jan niet getest... maar volgens mij doe jij eerder wat fout.
Ik heb Exact gedaan wat er staat hij doet niet het veld selecteren dat je erin kan typen zonder het aan te klikken dus.

<?
<?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>";

?>

Reageren