Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 204
  • Last Modified:

javascript question

I found this possible solution but do not know how to implement it.

I have a button that when clicked it should go to the textbox4 and scroll to it...
0
zachvaldez
Asked:
zachvaldez
1 Solution
 
Gurvinder Pal SinghCommented:
check this simple example
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
	<script src="jquery-1.4.2.min.js"></script>
	<script>

		function goToByScroll(id)
		{
			$('html,body').animate({
				scrollTop: $("#"+id).offset().top},
				'slow', function(){
					$("#"+id).focus();
				});
		}

	</script>
</HEAD>

<BODY>

	<input type="button" onclick="goToByScroll('text1')">

	some space before textbox
	<br>
	<br>
	<br>
	<br>
	<br>
	<br>
	<br>
	<br>
	some space before textbox
	<br>
	<br>
	<br>
	<br>
	<br>
	<br>
	<br>
	<br>
	some space before textbox
	<br>
	<br>
	<br>
	<br>
	<br>
	<br>
	<br>
	<br>
	some space before textbox
	<br>
	<br>
	<br>
	<br>
	<br>
	<br>
	<br>
	<br>
	some space before textbox
	<br>
	<br>
	<br>
	<br>
	<br>
	<br>
	<br>
	<br>
	some space before textbox
	<br>
	<br>
	<br>
	<br>
	<br>
	<br>
	<br>
	<br>
	some space before textbox
	<br>
	<br>
	<br>
	<br>
	<br>
	<br>
	<br>
	<br>
	some space before textbox
	<br>
	<br>
	<br>
	<br>
	<br>
	<br>
	<br>
	<br>
	some space before textbox
	<br>
	<br>
	<br>
	<br>
	<br>
	<br>
	<br>
	<br>
	some space before textbox
	<br>
	<br>
	<br>
	<br>
	<br>
	<br>
	<br>
	<br>
	some space before textbox
	<br>
	<br>
	<br>
	<br>
	<br>
	<br>
	<br>
	<br>
	some space before textbox
	<br>
	<br>
	<br>
	<br>
	<br>
	<br>
	<br>
	<br>

	<input type="text" id="text1">

</BODY>
</HTML>

Open in new window

0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now