Discussion:
Setting focus using document.getElementById
(too old to reply)
vic
2008-03-15 01:07:32 UTC
Permalink
Hello,

I am trying to set focus to a specific field using document.getElementById.
When the code is run I get the alert message but the focus to the text field
bill_fname seems to be ignored. Would someone be so kind as to check my
code and tell me what is wrong??

Following is the code:


$bill_address2 = $_POST['address2'];
$bill_city = $_POST['city'];
$bill_state = $_POST['state'];
$bill_zip = $_POST['zip'];
$bill_searchState = $_POST['state'];
$bill_searchCountry = $_POST['country'];

?>
<script type="text/javascript">
var sErr_message = "<?php echo "Set the focus to billing first name";
?>."
alert (sErr_message)
//document.purchase.bill_fname.focus();
document.getElementById('bill_fname').focus()

</script>
<?php
.....
?>


Thanks,

Vic
ZZyZX
2008-05-15 19:08:07 UTC
Permalink
Post by vic
Hello,
I am trying to set focus to a specific field using
document.getElementById. When the code is run I get the alert message
but the focus to the text field bill_fname seems to be ignored. Would
someone be so kind as to check my code and tell me what is wrong??
$bill_address2 = $_POST['address2'];
$bill_city = $_POST['city'];
$bill_state = $_POST['state'];
$bill_zip = $_POST['zip'];
$bill_searchState = $_POST['state'];
$bill_searchCountry = $_POST['country'];
?>
<script type="text/javascript">
var sErr_message = "<?php echo "Set the focus to billing first
name"; ?>."
alert (sErr_message)
//document.purchase.bill_fname.focus();
document.getElementById('bill_fname').focus()
</script>
<?php
.....
?>
Thanks,
Vic
Test

Loading...