Web Design Forums

Javascript, AJAX, and JSON

Having problems with Javascript? Need help picking a library? Post your questions here.

setting focus



Site of the Month Nominations
ENTER YOUR SITE NOW!

Reply
 
LinkBack Thread Tools
Old November 25 '03, 03:29 AM (#1)
gareth is offline
New Member!
 
gareth's Avatar
 
Join Date: November 2003
Posts: 6
gareth
setting focus

can someone pls give me a hint how i can set the focus into a particular field of a form. i.e. for example i would like that when a user clicks the "reset button", i would like that the first field of the form will get the focus.

thx for your help!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old November 25 '03, 07:02 PM (#2)
nocloset is offline
WDF Regular
 
nocloset's Avatar
 
Join Date: September 2003
Posts: 108
nocloset
The code below is stolen from W3Schools.com (To view the link you have to Register). Hope it helps.

<html>
<head>
<script type="text/javascript">
function setfocus()
{
document.forms[0].field.focus()
}
</script>
</head>
<body>
<form>
<input type="text" name="field" size="30">
<input type="button" value="Get Focus" onclick="setfocus()">
</form>
</body>
</html>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old November 26 '03, 02:36 AM (#3)
skrlin is offline
JavaScript Enthusiast
 
skrlin's Avatar
 
Join Date: April 2003
Location: Illinois
Posts: 562
skrlin has disabled reputation
Send a message via AIM to skrlin
This also applies to windows.

EX:
PHP Code:
<html>
<
head>
 <
title>Window Focus Example</title>
 <
script type="text/javascript">
  var 
myWin window.open(); // opens new window
  
myWin.document.write('new window'); // writes text to new window
  
self.focus(); // brings first window back into focus

  
function myWinFocus() {
   
/* this next line waits 5 seconds... */
   
setTimeout('myWin.focus()',5000); // then focuses the window you opened
  
}
 
</script>
</head>
<body onLoad="myWinFocus()">
 <!-- some html stuff here  -->
</body>
</html> 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old November 26 '03, 03:34 AM (#4)
gareth is offline
New Member!
 
gareth's Avatar
 
Join Date: November 2003
Posts: 6
gareth
thx for your information!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

  Web Design Forums » Programming Help » Javascript, AJAX, and JSON

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


 
User Infomation
Your Avatar

Site Of The Month

Ticket Cake
Ticket Cake

Ticket Cake is a drupal based event ticketing platform. It features that ability to browse events and share them.

Nominate Your Site Now!

Advertisement
WolfCMS.org

Latest Articles
- by RickM
- by bfsog

Advertisement

Partner Links



All times are GMT -4. The time now is 10:12 AM.


WebDesignForums.net is Copyright © 2010 RikeMedia.

SEO by vBSEO

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163