PDA

View Full Version : Form Focus


tsbarnes
02-12-2003, 03:49 PM
I have a invisible field that appears based on a certain selection from a drop down box. In the invisible field I have a default value '$'. When this field appears I want to give it focus, but I want the cursor to be to the right of my default value. I know this may seem very confusing so it may be easier to visit the page:

www.bearinglocator.com/bl/default.asp?action=register

Go down to the field "Do you have a minimum order" and in the drop down box select yes. Keeping in mind I want the cursor to be to the right of the $.

How can I do this?


Thanks,

tsbarnes

Danne
02-12-2003, 03:55 PM
Using styles, you could do something like:

<input type="text" style="text-align:right;">

I'm not sure if the cursor itself will appear right of the $, though...

A1ien51
02-12-2003, 04:10 PM
you had me wondering, so I played with some code I had....I only wrote this IE, when I get off of work tonight I will try to do this with NN

<html>
<head>
<script>
function HighIt(){
str="$";
TRange=document.formname.elementname.createTextRange()
TRange.collapse(false)
strFound=TRange.findText(str)
TRange.select();
TRange.collapse(false)
}
</script>
</head>
<body onload="HighIt()">
<form name="formname">
<input type="text" name="elementname" value="$">
</form>
</body>
</html>

A1ien51
02-13-2003, 12:23 AM
Try this:

<html>
<head>
<script>
function HighIt(){
str="$";
if(document.all){
TRange=document.formname.elementname.createTextRange();
TRange.collapse(false)
strFound=TRange.findText(str)
TRange.select();
TRange.collapse(false)
}
else{
document.formname.elementname.focus();
}
}
</script>
</head>
<body onload="HighIt()">
<form name="formname">
<input type="text" name="elementname" value="$">
</form>
</body>
</html>