[PLUG] Javascript question

Holger Stephan holger at selover.net
Tue Oct 7 21:35:02 UTC 2003


Matt, 

When you dynamically create the page on the server side you don't have
to use JavaScript to determine which text field you want to put the
focus on. Just create the correct focus() dynamically. Otherwise this
may do the trick on the client side: 

...
<script type="text/javascript">
function setFocus()
{
	if (document.form1.textfield2.value == "two")
		document.form1.textfield2.focus()
	else
		document.form1.textfield1.focus()
}
</script>
</head>

<body onLoad="setFocus()">
<form name="form1">
    <input name="textfield1" type="text" value="one">
    <input name="textfield2" type="text" value="two">
...

- Holger (top posting subersive)

On Tue, 2003-10-07 at 16:46, Matt Alexander wrote:
> Does anyone know how I would send the focus to a text field based on its
> contents?  For example, I dynamically create an HTML table (containing
> input text fields) from an SQL query and I want to have the cursor
> automatically go to a certain field containing a certain string of text.
> Thanks,
> ~M





More information about the PLUG mailing list