By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,445 Members | 3,172 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,445 IT Pros & Developers. It's quick & easy.

Selecting a Text Field on Page Refresh

P: 1
I have the following simple page. I need to select the BARCODE text field everytime the page refreshes. I know this is pretty basic, but I'm just starting with Javascript. Thanks for the help.

[HTML]<head>

<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
<LINK href="css/radevice.css" type="text/css" rel="stylesheet">
<script language="JavaScript" src="/scripts/URLhandle.js" type="text/javascript"></script>
<script language="javascript" src="/scripts/refresh.js" type="text/javascript"></script>
<script language="javascript">
</script>
<SCRIPT LANGUAGE="JScript">
</SCRIPT>

<meta http-equiv="Refresh" content="10"

</head>

<body lang=EN-US style='tab-interval:.5in'>

<div class=Section1>

<h1 align=center

Line:3

</h1>




<table>


<td align=center><FONT SIZE="4">
Line:3
</td></tr>

<td align=center><FONT SIZE="4">
<form action="/rokform/WriteLogixTags" method="GET">
Pick Status:
<input type="hidden" name="redirect" value="/user/Web/HH.asp">
<input type="hidden" name="numtags" value="1">
<input type="hidden" name="t_1_tagname" value="RB3BoardFeedback">
<input type="hidden" name="t_1_slot" value="0">
<input type="hidden" name="t_1_type" value="STRING">
<input type="hidden" name="t_1_display" value="String">
<input type="hidden" name="t_1_changed" value="1">
<input type="input" name="t_1_value" value="<%ReadLogixTag("1,0","RB3BoardFeedback","ST RING");%>">

</form>
</td></tr>



[b]<td align=center width="50%"><FONT SIZE="4">

<form action="/rokform/WriteLogixTags" method="POST">
BARCODE:
<input type="hidden" name="redirect" value="/user/Web/HH.asp">
<input type="hidden" name="numtags" value="1">
<input type="hidden" name="t_1_tagname" value="RBGEHH1BCR">
<input type="hidden" name="t_1_slot" value="0">
<input type="hidden" name="t_1_type" value="STRING">
<input type="hidden" name="t_1_display" value="String">
<input type="hidden" name="t_1_changed" value="1">
<input type="input" name="t_1_value" value="<%ReadLogixTag("1,0","RBGEHH1BCR","STRING") ;%>">

<input type="submit" name="submit" value="Set Value">
</form>
</td>
</table>


</div>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

</div>

</body>

</html>[/HTML]
Jan 5 '08 #1
Share this Question
Share on Google+
4 Replies


Expert 100+
P: 785
just insert:
Expand|Select|Wrap|Line Numbers
  1. <BODY onLoad='document.getElementById("t_1_value").focus();'>
One tip from a long-time expert: don't use generators for your page, just learn HTML and do it manually!
Garbage like
Expand|Select|Wrap|Line Numbers
  1. <p class=MsoNormal><o:p>&nbsp;</o:p></p>
is an indicator that you used Microsoft Word or another microsoft-office-product to make this page!
They are doing nothing except slowing down your page and making modifications very difficult!
Jan 6 '08 #2

acoder
Expert Mod 15k+
P: 16,027
just insert:
Expand|Select|Wrap|Line Numbers
  1. <BODY onLoad='document.getElementById("t_1_value").focus();'>
That wouldn't quite work because the ID hasn't been set. If the id of the text field is set to "t_1_value", it should work as expected.

Agree with your tip :)
Jan 7 '08 #3

Expert 100+
P: 785
That wouldn't quite work because the ID hasn't been set. If the id of the text field is set to "t_1_value", it should work as expected.

Agree with your tip :)
But what you said is wrong for IE, I tested it.

example code, test it yourself.:
Expand|Select|Wrap|Line Numbers
  1. <input type=text name="myBox">
  2. <input type=text onChange="alert('You entered above: ' + document.getElementById('myBox').value)"'>
It seems that if an element does not have an "id", but a "name", then
getElementById() fetches the element as though the name would be its id.
Jan 8 '08 #4

acoder
Expert Mod 15k+
P: 16,027
But what you said is wrong for IE, I tested it.

example code, test it yourself.:
Expand|Select|Wrap|Line Numbers
  1. <input type=text name="myBox">
  2. <input type=text onChange="alert('You entered above: ' + document.getElementById('myBox').value)"'>
It seems that if an element does not have an "id", but a "name", then
getElementById() fetches the element as though the name would be its id.
Yes, I know that "works", but it's wrong and buggy. document.getElementById() should only fetch an element by its ID as its name suggests, not the element's name. This won't work in any of the other browsers.

To fetch an element by its name, we have document.getElementsByName().
Jan 8 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.