1

I have a problem which I have not been able to resolve. I've looked all over and tried everything. I have a number input field on my website. When users click anywhere within the number input, I want it to highlight what it currently contains. I use this.select() to do this. It works on all browers, except for Internet Explorer 8. It will even work on ie7, ie6, etc. When I tell it to alert a message onclick, it won't even do that, so I don't think it's a problem with this.select(). It just won't register that the input field has been clicked on unless you click directly on the number that's already there, but I want the user to click anywhere inside of the input field. I've tried using onclick, onmousedown, focus, I've tried surrounding it in a div, but nothing has worked for ie8. Any ideas? Here is the code:

<td id="week_1_day_2_div" width="90px" align="center" valign="middle">
<input type="number" id="week_1_day_2_numberbox" min="0" maxlength="5" size="5" 
value="10198" onclick="this.select()" onchange="checkInput(1,2,0)" max="99999"
style="background-color:transparent; height:20px; width:80px; border:1px solid 
#000000;">
</td>
thuey
  • 119
  • 1
  • 3
  • 13
  • Your problem must be elsewhere, as the code *as-is*, appears to work as expected in IE8 (as well as 7, 9, and 10) according to the following test: http://jsfiddle.net/qeNvP/1/. – Sampson May 15 '12 at 15:31
  • Hmm...you're right. That doesn't make any sense, though. I don't know what else could be affecting it or why it only happens in ie8. – thuey May 15 '12 at 15:40
  • Okay, when I removed the "background-color:transparent;" it started working. I'm not sure why, though. – thuey May 15 '12 at 15:55
  • Okay, after much searching, I found the answer to my question. Instead of using background-color:transparent, as an ie8 workaround, I changed it to a blank image as a background: background:url(blank.gif); This is where I found the answer: http://stackoverflow.com/questions/3997065/ie-css-bug-background-color-transparent-behaves-differently-to-background-colo – thuey May 15 '12 at 16:04
  • @barkingmonkey Can you put your comment as an answer and then mark it accepted? This will make it easier for people to see that this is solved. – Alex L May 16 '12 at 10:17

0 Answers0