views:

684

answers:

2

Hi,
I have a google suggest like utility on my page. It automatically fills a value in one of input type text box. In IE, after the value is being filled. It doesnt allow mouse to click in between and curor jumps to the end always. Also with the left and right keys,the cursor jumps to the beginning. What's the cause.

Thanks

<div id='input-div' class='inputblock'>
<form action="javascript:void(0);" name="GetVal">
<table>
<tr>
<td>
<div>
<input id="starttextbox" class="big" onclick="textboxClick(this)"   onblur="textboxBlur(this)" onkeyup="javascript:check_place(this)" type="text" name="start" autocomplete="off"/>
</div>
<div id='suggestdividstart' class='suggestDivClass'></div>
</td>
<td style='cursor:pointer' ><img style='display:none;' id='swaptd' style='cursor:pointer' src='images/swap.png' width='20' height='20' onclick='swaproute();return false;' title='click for reverse route'/>
</td>
<td>
<div>
<input id="endtextbox" class="smallhidden" onclick="textboxClick(this)"  onblur="textboxBlur(this)" onkeyup="javascript:check_place(this)" type="text" name="end" autocomplete="off" />
</div>
<div id='suggestdividend' class='suggestDivClass'></div>
</td><td>
<img  name="GoVid" id="GoVid" onclick="alert('Loading plz. wait')" src='images/locate.gif' tabindex='0' style='cursor:pointer' class="vidteq" value="Locate"  href="javascript:void(0);"/>
</td></tr>
</table>
<div class="help" id="helpdiv"></div>
</form>
</div>

What javascript does is:

if(whichBox=='start') {
//clearSuggestDiv('start');
document.GetVal.start.value=place_selected_name;
}
else {
//clearSuggestDiv('end');
document.GetVal.end.value=place_selected_name;
}
A: 

What does your HTML page looks like? It sounds like javascript is doing something wrong.

tehvan
u can check it at www.click2cmap.com
Rakesh
+2  A: 

What's the cause.

textboxClick() writes to input.value on every click. You write to the value, you lose the cursor position. So write to .value as little as possible, unless you're capable of getting cross-browser cursor handling right, which judging by the quality of the rest of the scripting on this page I doubt.

bobince
Sounds good. Is there a way to retrieve the cursor position in IE?
Rakesh
http://stackoverflow.com/questions/235411/is-there-an-internet-explorer-approved-substitute-for-selectionstart-and-selectio
bobince