1
<script>
function focusit(){
var qbox = document.getElementById('q');
qbox.focus();
qbox.value = qbox.value;
}
</script>

<body onload="focusit();">

<textarea name='q' rows='3' cols='100' id='q'><?php sone code here ?></textarea>

this textarea is used to type in queries. when the page loads this is set on focus - no problem because it dosent have text. After query is submitted the page is loaded again this the text inside of it but the focus is before the text. Now in FFX recently this dosent word. A while back this dosent worked in opera. :( How can i code this to word on all browsers? .. basically just like in google's box

faq
  • 2,965
  • 5
  • 27
  • 35
  • What does `qbox.value = qbox.value;` add? – pimvdb Aug 20 '11 at 13:06
  • Related: http://stackoverflow.com/questions/637287/how-can-you-move-the-cursor-to-the-last-position-of-a-textarea-in-javascript – Digital Plane Aug 20 '11 at 13:08
  • it is a code i got form the net – faq Aug 20 '11 at 13:09
  • I don't have a detailed answer for you, but I've seen this done use range. I believe range is mostly used to select the text that you have, but it should also allow you to put the cursor at the end. I how there is an easier solution than this. – natedavisolds Aug 20 '11 at 13:11
  • If you want people to replace or decide to go to end themselves, add a qbox.select() – mplungjan Aug 20 '11 at 14:11

1 Answers1

1

You should try posting the value on that page. And when page loads again just show that posted value in the textarea.

i.e.

$value = $_POST['q'];


<textarea name='q' rows='3' cols='100' id='q'><?php echo $value; ?></textarea>
pimvdb
  • 151,816
  • 78
  • 307
  • 352
talha2k
  • 24,937
  • 4
  • 62
  • 81