i am using focus() function of javascript it works great in FireFox but does blunder's in IE is there any problem of focus() in IE .... OR some fix OR.. some other method for IE...
Please Reply Fast... URGENT..
6 1652 gits 5,390
Expert Mod 4TB
what do you try to focus()? show the code that makes the problem ... typically focus() works ...
kind regards
i have a form which is toooo much complex in structure .... basically i am developing an online inventory system for my company where i am using barcode reader... i am using barcode reader to scan product UPC and SNO......
warning !!!!!! its too junckyyy..... i am a beginner ..... -
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
<html xmlns="http://www.w3.org/1999/xhtml">
-
<head>
-
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-
<meta http-equiv="Content-Script-Type" content="text/javascript" />
-
<script language="javascript" type="text/javascript" src="add_sr_no.js"></script>
-
<script type="text/javascript" src="../js/calendar.js"></script>
-
<script type="text/javascript" src="../js/calendar-en.js" ></script>
-
<script type="text/javascript" src="../js/calendar-setup.js"></script>
-
-
<link href="pur_invoice_entry.css" rel="stylesheet" type="text/css" />
-
<link rel="stylesheet" type="text/css" media="all" href="../js/calendar-system.css" title="win2k-cold-1" />
-
<title><? echo $title;?></title>
-
</head>
-
-
<body onload="document.getElementById('txt_upc_code_1').focus()">
-
<div id="header">
-
<h3>Purchase Order Entry</h3></div>
-
<form id="frm_pur_in_entry" name="frm_pur_in_entry" method="post" action="#" onsubmit="return onsubmit_handle();">
-
<input name="sn_id_counter" id="sn_id_counter" type="hidden" value="1" />
-
<input name="sn_name_counter" id="sn_name_counter" type="hidden" value="1" />
-
<table id="tab_1">
-
<tr>
-
<td width="105" class="lab">Invoice#</td>
-
<td width="81" class="field"><input name="txt_invoice_number" type="text" id="txt_invoice_number" size="12" /></td>
-
<td width="104" class="lab">Inv. Date</td>
-
<td width="125" class="field"><input name="txt_invoice_date" type="text" id="txt_invoice_date" size="8" />
-
<input type="button" name="btn_in_date" id="btn_in_date" value="..." /></td>
-
<td width="105" class="lab">Supplier Code</td>
-
<td width="69" class="field"><select name="sel_supplier" id="sel_supplier"></select></td>
-
<td width="105" class="lab">Sales Rep</td>
-
<td width="220" class="field"><input name="txt_sales_rep" type="text" id="txt_sales_rep" /></td>
-
</tr>
-
</table>
-
</table>
-
<script type="text/javascript">
-
Calendar.setup({
-
inputField : "txt_invoice_date", // id of the input field
-
ifFormat : "%m/%d/%Y", // format of the input field
-
button : "btn_in_date", // trigger for the calendar (button ID)
-
singleClick : true, // double-click mode
-
step : 1 // show all years in drop-down boxes (instead of every other year as default)
-
});
-
</script>
-
<p></p>
-
<table id="tab_2">
-
<tr>
-
<td width="104" class="lab">P.O. Number</td>
-
<td width="76" class="field"><input name="txt_p_o_number" type="text" id="txt_p_o_number" size="12" /></td>
-
<td width="179" class="lab">P.O. Date</td>
-
<td width="167" class="field"><input name="txt_p_o_date" type="text" id="txt_p_o_date" size="8" />
-
<input type="button" name="btn_pur_date" id="btn_pur_date" value="..." /></td>
-
<td width="104" class="lab">Ordered By</td>
-
<td width="292" class="field"><input name="txt_order_by" type="text" id="txt_order_by" /></td>
-
</tr>
-
<tr>
-
</table>
-
<script type="text/javascript">
-
Calendar.setup({
-
inputField : "txt_p_o_date", // id of the input field
-
ifFormat : "%m/%d/%Y", // format of the input field
-
button : "btn_pur_date", // trigger for the calendar (button ID)
-
singleClick : true, // double-click mode
-
step : 1 // show all years in drop-down boxes (instead of every other year as default)
-
});
-
</script>
-
<p></p>
-
<div style="overflow:auto; width:950px; height: 450px; margin-left:auto; margin-right:auto;">
-
<table id="tb_3">
-
<thead>
-
<tr>
-
<th>UPC Code</th>
-
<th>Product</th>
-
<th>Quantity</th>
-
<th>Price</th>
-
<th width="140">Serial Number</th>
-
</tr>
-
</thead>
-
<tbody id="tb">
-
<tr id="tr_1">
-
<td><input name="txt_upc_code_1" id="txt_upc_code_1" type="text" onchange="check_upc(this.value,'txt_desc_1','pro_id_1',1);" /><input name="pro_id_1" id="pro_id_1" type="hidden" value="" /></td>
-
<td><input name="txt_desc_1" id="txt_desc_1" type="text" /></td>
-
<td><input name="txt_quantity_1" id="txt_quantity_1" type="text" value="0" size="5"/></td>
-
<td><input name="txt_price_1" id="txt_price_1" type="text" size="5" /></td>
-
<td><div class="sno_1" id="sno_1" style="text-align:left;"><input name="txt_serial_1[]" id="txt_serial_1_1" type="text" value="" onchange="check_serial(this.value,document.getElementById('pro_id_1').value,1,1,'txt_quantity_1');"/></div>
-
<div class="sno_btn_1" id="sno_btn_1" style="text-align:left;"></div></td>
-
</tr>
-
</tbody>
-
-
<tfoot>
-
<tr>
-
<td colspan="5"><input name="btn_sub" type="submit" value="Submit"/><input name="btn_clear" type="reset" value="Clear"/></td>
-
</tr>
-
</tfoot>
-
-
</table>
-
</div>
-
</form>
-
</body>
-
</html>
-
-
-
-
-
//function for handling onsumit event
-
function onsubmit_handle()
-
{
-
-
//first call sajax function
-
return false;
-
}
-
-
-
-
function check_upc(upc,desc,pro_id,upc_name_count)
-
{
-
-
if(upc_name_count>1)
-
{
-
-
for(var i=1;i<upc_name_count;i++)
-
{
-
var val = document.getElementById('txt_upc_code_'+i).value;
-
if(val==upc)
-
{
-
alert("UPC Code Already Scanned");
-
document.getElementById('txt_upc_code_'+upc_name_count).value="";
-
document.getElementById('txt_upc_code_'+upc_name_count).focus();
-
return false;
-
}
-
}
-
-
}
-
-
document.getElementById('txt_serial_'+upc_name_count+'_1').focus();
-
if(upc.length==0)
-
{
-
alert("Please Scan The Product UPC Code");
-
return false;
-
}
-
else
-
{
-
-
var xmlhttp=false; //Clear our fetching variable
-
try {
-
xmlhttp = new ActiveXObject('Msxml2.XMLHTTP'); //Try the first kind of active x object… for IE
-
} catch (e) {
-
try {
-
xmlhttp = new ActiveXObject('Microsoft.XMLHTTP'); //Try the second kind of active x object for IE
-
} catch (E) {
-
xmlhttp = false;
-
}
-
}
-
if (!xmlhttp && typeof XMLHttpRequest!='undefined') { //for Mozilla
-
xmlhttp = new XMLHttpRequest();//If we were able to get a working active x object, start an XMLHttpRequest
-
-
}
-
xmlhttp.open('GET','../pur_invoice_entry/check_upc.php?upc='+upc, false);
-
xmlhttp.send(null);
-
var content = xmlhttp.responseText;
-
-
if(content!="NO")
-
{
-
var val = content.split("-");
-
document.getElementById(pro_id).value = val[0];
-
document.getElementById(desc).value=val[1]+"-"+val[2];
-
-
}
-
else
-
{
-
alert("No Product With This UPC Code. You Have To First Register Your Product");
-
}
-
}
-
-
}
-
-
-
-
-
-
//function for checking value already scanned or its UPC using AJAX
-
function check_serial(sno,pro_id,sn_name_count,sn_id_count,quantity)
-
{
-
-
if(sn_name_count>=1 || sn_id_count>=1)
-
{
-
-
var g_sn_n_c = document.getElementById('sn_name_counter').value;
-
-
if(document.getElementById('txt_upc_code_'+sn_name_count).value == sno)
-
{
-
alert("This IS UPC Code Please Scan OR Enter The Serial Number");
-
document.getElementById("txt_serial_"+sn_name_count+"_"+sn_id_count).value="";
-
document.getElementById("txt_serial_"+sn_name_count+"_"+sn_id_count).focus();
-
return false;
-
-
}
-
-
-
-
for(var i=1;i<=g_sn_n_c;i++)
-
{
-
var up = document.getElementById('txt_upc_code_'+i).value;
-
if(up==sno)
-
{
-
var j=1;
-
while(j>=1)
-
{
-
-
if(document.getElementById('txt_serial_'+i+'_'+j).value.length==0 )
-
{
-
document.getElementById("txt_serial_"+sn_name_count+"_"+sn_id_count).value="";
-
document.getElementById("txt_serial_"+i+"_"+j).focus();
-
}
-
j++;
-
}
-
}
-
}
-
-
for(var k=1;k<sn_id_count;k++)
-
{
-
-
var val = document.getElementById('txt_serial_'+sn_name_count+'_'+k).value;
-
if(val==sno)
-
{
-
alert("Serial Number Already Scanned");
-
document.getElementById('txt_serial_'+sn_name_count+'_'+sn_id_count).value="";
-
document.getElementById('txt_serial_'+sn_name_count+'_'+sn_id_count).focus();
-
return false;
-
}
-
-
}
-
-
}
-
-
-
-
if(sno.length==0)
-
{
-
alert("Please Sacn OR Enter The Serial Number");
-
return false;
-
}
-
else
-
{
-
var xmlhttp=false; //Clear our fetching variable
-
try {
-
xmlhttp = new ActiveXObject('Msxml2.XMLHTTP'); //Try the first kind of active x object… for IE
-
} catch (e) {
-
try {
-
xmlhttp = new ActiveXObject('Microsoft.XMLHTTP'); //Try the second kind of active x object for IE
-
} catch (E) {
-
xmlhttp = false;
-
}
-
}
-
if (!xmlhttp && typeof XMLHttpRequest!='undefined') { //for Mozilla
-
xmlhttp = new XMLHttpRequest();//If we were able to get a working active x object, start an XMLHttpRequest
-
-
}
-
xmlhttp.open('GET','../pur_invoice_entry/check.php?pro_id='+pro_id+'&sno='+sno, false);
-
xmlhttp.send(null);
-
var val = xmlhttp.responseText;
-
if(val=="true")
-
{
-
add_Sr_No(sn_name_count,sn_id_count,quantity);
-
}
-
else if(val=="upc")
-
{
-
new_product(sno);
-
document.getElementById('txt_serial_'+sn_name_count+"_"+sn_id_count).value = "";
-
}
-
else
-
{
-
alert(val);
-
document.getElementById('txt_serial_'+sn_name_count+"_"+sn_id_count).value = "";
-
document.getElementById('txt_serial_'+sn_name_count+"_"+sn_id_count).focus();
-
return false;
-
}
-
}
-
}
-
-
-
-
-
-
-
-
-
-
-
//function for adding single element for serial number
-
-
function add_Sr_No(sn_name_count,sn_id_count,quantity)
-
{
-
-
-
//var sn_id_counter = parseInt(document.getElementById('sn_id_counter').value);
-
//var sn_name_counter = parseInt(document.getElementById('sn_name_counter').value);
-
var sn_id_counter = sn_id_count;
-
var sn_name_counter = sn_name_count;
-
var quant = parseInt(document.getElementById(quantity).value);
-
-
-
-
-
var sn_div_id = 'sno_'+sn_name_counter;
-
var sn_div = document.getElementById(sn_div_id);
-
var sn_btn_div = document.getElementById('sno_btn_'+sn_name_counter);
-
-
sn_id_counter=sn_id_counter+1;
-
var sn_inp = document.createElement('input');
-
var sn_inp_id = "txt_serial_"+sn_name_counter+"_"+sn_id_counter;
-
var sn_inp_name = "txt_serial_"+sn_name_counter+"[]";
-
sn_inp.setAttribute('id',sn_inp_id);
-
sn_inp.setAttribute('name',sn_inp_name);
-
sn_inp.setAttribute('type','text');
-
sn_inp.setAttribute('value','');
-
var pro_id = document.getElementById("pro_id_"+sn_name_counter).value;
-
sn_inp.onchange=function() {check_serial(this.value,pro_id,sn_name_counter,sn_id_counter,quantity);}
-
-
-
//create a remove button
-
var img=document.createElement('img');
-
var img_id = "img_"+sn_name_counter+"_"+sn_id_counter;
-
img.setAttribute('src','delete.gif');
-
img.setAttribute('id',img_id);
-
img.onclick=function(){remove(sn_inp_id,sn_div_id);remove(img_id,sn_div_id);};
-
-
var sn_br = document.createElement('br');
-
-
sn_div.appendChild(sn_br);
-
sn_div.appendChild(sn_inp);
-
-
sn_div.appendChild(img);
-
-
document.getElementById(sn_inp_id).focus();
-
document.getElementById('sn_id_counter').value=sn_id_counter;
-
document.getElementById(quantity).value=quant+1;
-
-
-
return false;
-
}
-
-
-
//function for flag value
-
function flag_value()
-
{
-
document.getElementById("flag").value="end";
-
return true;
-
}
-
-
-
function new_product(upc)
-
{
-
-
document.getElementById('sn_id_counter').value=1;
-
var sn_name_counter = parseInt(document.getElementById('sn_name_counter').value);
-
var sn_id_counter = parseInt(document.getElementById('sn_id_counter').value);
-
sn_name_counter=sn_name_counter+1;
-
-
-
-
var tb = document.getElementById('tb');
-
var tr = document.createElement('tr');
-
-
var tr_id = "tr_"+sn_name_counter;
-
tr.setAttribute('id',tr_id);
-
-
var td_1 = document.createElement('td');
-
-
var pro_id=document.createElement('input');
-
var pro_id_1_id = "pro_id_"+sn_name_counter;
-
var pro_id_1_name = "pro_id_"+sn_name_counter;
-
-
pro_id.setAttribute('id',pro_id_1_id);
-
pro_id.setAttribute('name',pro_id_1_name);
-
pro_id.setAttribute('type','hidden');
-
-
var inp_1=document.createElement('input');
-
var inp_1_id = "txt_upc_code_"+sn_name_counter;
-
var inp_1_name = "txt_upc_code_"+sn_name_counter;
-
-
inp_1.setAttribute('id',inp_1_id);
-
inp_1.setAttribute('name',inp_1_name);
-
inp_1.setAttribute('type','text');
-
inp_1.onchange=function() {check_upc(this.value,inp_2_id,pro_id_1_id,sn_name_counter);}
-
-
var td_2 = document.createElement('td');
-
var inp_2=document.createElement('input');
-
var inp_2_id = "txt_desc_"+sn_name_counter;
-
var inp_2_name = "txt_desc_"+sn_name_counter;
-
-
inp_2.setAttribute('id',inp_2_id);
-
inp_2.setAttribute('name',inp_2_name);
-
inp_2.setAttribute('type','text');
-
-
-
-
-
var td_3 = document.createElement('td');
-
var inp_3=document.createElement('input');
-
var inp_3_id = "txt_quantity_"+sn_name_counter;
-
var inp_3_name = "txt_quantity_"+sn_name_counter;
-
-
inp_3.setAttribute('id',inp_3_id);
-
inp_3.setAttribute('name',inp_3_name);
-
inp_3.setAttribute('type','text');
-
inp_3.setAttribute('value','0');
-
inp_3.setAttribute('size','5');
-
-
-
-
-
var td_4 = document.createElement('td');
-
var inp_4=document.createElement('input');
-
var inp_4_id = "txt_price_"+sn_name_counter;
-
var inp_4_name = "txt_price_"+sn_name_counter;
-
-
inp_4.setAttribute('id',inp_4_id);
-
inp_4.setAttribute('name',inp_4_name);
-
inp_4.setAttribute('type','text');
-
inp_4.setAttribute('size','5');
-
-
-
var td_5 = document.createElement('td');
-
var inp_5=document.createElement('input');
-
var inp_5_id = "txt_serial_"+sn_name_counter+"_"+sn_id_counter;
-
var inp_5_name = "txt_serial_"+sn_name_counter+"[]";
-
-
-
inp_5.setAttribute('id',inp_5_id);
-
inp_5.setAttribute('name',inp_5_name);
-
inp_5.setAttribute('type','text');
-
inp_5.setAttribute('value','');
-
//inp_5.onchange=function() {add_Sr_No(sn_name_counter,sn_id_counter,inp_3_id);}
-
inp_5.onchange=function() {check_serial(this.value,document.getElementById(pro_id_1_id).value,sn_name_counter,sn_id_counter,'txt_quantity_'+sn_name_counter);}
-
-
-
var sn_div = document.createElement('div');
-
var sn_btn_div_id = 'sno_'+sn_name_counter;
-
var sn_div_class = 'sno_'+sn_name_counter;
-
sn_div.setAttribute('id',sn_btn_div_id);
-
sn_div.setAttribute('class',sn_div_class);
-
//sn_div.style.text-align = 'left';
-
sn_div.appendChild(inp_5);
-
-
-
var sn_btn_div = document.createElement('div');
-
var sn_btn_div_id = 'sno_btn_'+sn_name_counter;
-
var sn_btn_div_class = 'sno_btn_'+sn_name_counter;
-
sn_btn_div.setAttribute('id',sn_btn_div_id);
-
sn_btn_div.setAttribute('class',sn_btn_div_class);
-
-
-
-
-
-
td_1.appendChild(inp_1);
-
td_1.appendChild(pro_id);
-
td_2.appendChild(inp_2);
-
td_3.appendChild(inp_3);
-
td_4.appendChild(inp_4);
-
td_5.appendChild(sn_div);
-
td_5.appendChild(sn_btn_div);
-
-
-
-
tr.appendChild(td_1);
-
tr.appendChild(td_2);
-
tr.appendChild(td_3);
-
tr.appendChild(td_4);
-
tr.appendChild(td_5);
-
tb.appendChild(tr);
-
-
document.getElementById('txt_upc_code_'+sn_name_counter).focus();
-
document.getElementById('sn_name_counter').value=sn_name_counter;
-
document.getElementById('txt_upc_code_'+sn_name_counter).value= upc;
-
check_upc(upc,inp_2_id,pro_id_1_id,sn_name_counter);
-
-
-
-
-
}
-
-
//function for removing single added element
-
function remove(remove_id,parent_div){
-
//var counter = parseInt(document.getElementById('counter').value);
-
//var quantity = parseInt(document.getElementById('txt_quant_s').value);
-
//if(counter>1)
-
//{
-
-
var parent_div = document.getElementById(parent_div);
-
-
var remove_id = document.getElementById(remove_id);
-
-
parent_div.removeChild(remove_id);
-
-
//var num=counter-1;
-
//document.getElementById('counter').value=num;
-
//document.getElementById('txt_quant_s').value=--quantity;
-
//if(counter==2)
-
/*{
-
var quan=document.getElementById('1');
-
quan.removeAttribute('readonly',true);
-
quan.removeAttribute('readOnly','readonly');//for internet explorer there should be capital 'O' in readonly
-
}
-
-
}
-
else
-
{
-
alert("If You Want To Clear All Click Discard");
-
}*/
-
}
-
-
gits 5,390
Expert Mod 4TB
which focus doesn't work? the one from the onload or those that should be set later on?
kind regards
which focus doesn't work? the one from the onload or those that should be set later on?
kind regards
those one's that i set later on....
gits 5,390
Expert Mod 4TB
it seems that you assign the same id and name to the textboxes that should be focused later on? - var pro_id=document.createElement('input');
-
-
var pro_id_1_id = "pro_id_"+sn_name_counter;
-
var pro_id_1_name = "pro_id_"+sn_name_counter;
i think i remember that IE has problems with that - try to make them different.
kind regards
gits 5,390
Expert Mod 4TB
it seems that you always assign the same id and name to the textboxes that should be focused later on (for example)? - var pro_id=document.createElement('input');
-
-
var pro_id_1_id = "pro_id_"+sn_name_counter;
-
var pro_id_1_name = "pro_id_"+sn_name_counter;
i think i remember that IE has problems with that - try to make them different.
kind regards
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Dave |
last post by:
Hi all,
I have a problem with a query. (well, I actually have a few problems...)
Here is my query.
select FOCUS.SiteName, FOCUS.URL, OTWAdCars.* , REGION.SiteName as
RegionSite, REGION.URL...
|
by: Nitin |
last post by:
Hi
I have created function to check date and time. at the time of
execution, if date is left empty the function returns the error
message but then the focus goes to next field. Next filed is for...
|
by: Ricardo Garcia |
last post by:
hi, i have the next situation:
an index.html that has 2 frames (the main and the navigation bar)
and the next problem (in IE, in Mozilla it works properly):
when i start to scroll in the main...
|
by: Peter Wright |
last post by:
Hi all.
Hopefully this should demonstrate the problem I'm having:
http://flooble.net/~pete/focus-problem-demo/
(I'm testing it in Mozilla only, but I'm not sure if it's actually a...
|
by: nizar.jouini |
last post by:
I have web page that contains two links.
link "a" and link "b". When I click on "a" a small window should pop
up. when I click on "b" another small window should pop up. So what you
should see now...
|
by: avnrao |
last post by:
Hi,
I am facing a problem with control.focus (javascript). Here is the
description of the issue.
1. I have 2 aspx files. on Aspx1 I have button named NewRow. Clicking on
this, will redirect...
|
by: clickon |
last post by:
For testing purposes i have got a 2 step WizardControl. Eqach step contains
a text box, TextBox1 and TextBox2 respectively. If i put the following code
in the respective activate event handlers for...
|
by: ngkuhlmann |
last post by:
I have a strange problem.
I have a tab control with 5 tabs. When I click one of the tabs the tab
show its information just fine, however when I test the focus, without
moving and within a timer...
|
by: jan.loucka |
last post by:
Hi,
I looked around for this specific problem but could not find any
answer - there's few things in VB but still nothing exactly like this
so I'd appreciate any help.
We're writing C# WinForm...
|
by: Drelus |
last post by:
I'm using an Ajax call to open a search box in the page and I want the focus to go to the box automatically.
So, in the httpObject.responseText, I tried sending the following in addition to the...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |