PDA

View Full Version : issue with <input type='textbox'>



venkata ande
11-12-2008, 06:50 AM
i have a <input type='textbox'> which has some text n when i click anywhere inside it, the cursor has to be move to the end of the string

one more issue is like:

the above <input type> with some text inside it is in readonly mode n when i click inside the <input type> it has to change to edit mode with the cursor aligned to extreme right of the string.

Any one with quick response would be highly appreciated as it is required on urgent basis.

Nile
11-12-2008, 12:50 PM
1) It's:


<input type="text">

2) Make sure that you don't have any align on your element:


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

3) If your not, make your code this:


<input type="text" style="text-align:left">

jscheuer1
11-12-2008, 03:17 PM
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
function setCaretTo(obj, pos){
if(obj.selectionStart){
obj.focus();
obj.setSelectionRange(pos, pos);
} else if(obj.createTextRange){
var range = obj.createTextRange();
range.move('character', pos);
range.select();
}
};

function readWrite(t){
if(!t.onclick.clicked){
t.onclick.clicked=true;
t.removeAttribute('readonly', 0);
setCaretTo(t, t.value.length);
t.blur();
t.focus();
}
};
</script>
</head>
<body>
<input type="text" readonly onclick="readWrite(this);" value="something"><br>
</body>
</html>