Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

invisible, "focusable" element

Status
Not open for further replies.

blueindian1

Programmer
Apr 24, 2001
150
US
Hello,

Can anyone tell me how to create an invisible form element that I can give focus to? I don't care what it is, as long as i can adjust the size (needs to be super small) and user's can't see it.

thanks,

rich
 
I do not understand what you could do with it, but try this:

Code:
<form name = &quot;form1&quot;>
	<input type = &quot;text&quot; name = &quot;text1&quot; value = &quot;&quot;>

	<div id = &quot;myDiv1&quot; style = &quot;
		position:absolute;
		left:-500; top:-500;
		width:250; height:10;&quot;>
		<input type = &quot;text&quot; name = &quot;text2&quot; value = &quot;&quot;>
	</div>
	<br>
	<input type = &quot;submit&quot; name = &quot;button1&quot; value = &quot; OK &quot;>
</form>

<script language = javascript>
	document.form1.text2.focus();
</script>


vlad
 
when the page has loaded you will not see the text box but you can type some text, then press the show button and you will see the text you typed in the textbox, proving that the text box had focus:

<body onload=&quot;document.Test.textInvisible.focus()&quot;>
<form name=Test>
<input name=&quot;textInvisible&quot; type=text size=30 style=&quot;width:0; height:0&quot;>
<input type=button onclick=&quot;ShowIt()&quot; value=&quot;Show&quot;>
<script>

function ShowIt()
{
var textBox = document.Test.textInvisible
textBox.style.height=&quot;20px&quot;
textBox.style.width=&quot;100px&quot;
}
</script>
</form>
</body>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top