WebProWorld Part of WebProNews.com
Page One Link To Us Edit Profile Private Messages Archives FAQ RSS Feeds  
 

Go Back   WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Subscribe to the Newsletter FREE!


Register FAQ Members List Calendar Arcade Chatbox Mark Forums Read

Web Programming Discussion Forum Working with an API? Developing a plugin? Writing a Mod or script for your favorite blog, Web 2.0 site or Forum? Welcome.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 09-13-2005, 08:09 AM
WebProWorld Pro
 

Join Date: Jun 2004
Location: Weymouth, UK
Posts: 124
EmmaGale RepRank 0
Default Form cursor focus

ASP/VBScript Forms

Could someone please tell me how I get the cursor to focus on the top box when a page is opened.

I have a number of pages which request information and every time the paeg opens you have to place the cursor in the top box.

kind regards
emma
Reply With Quote
  #2 (permalink)  
Old 09-13-2005, 08:12 AM
WebProWorld Pro
 

Join Date: Sep 2005
Location: Manchester, UK
Posts: 257
mikesmith76 RepRank 0
Default

you'll need to do this with javascript as opposed to ASP as it's actually done by the clients browser when they load the page. The onload event of the body tag should do it e.g.

<body onload="javascript: somefield.focus();">

This should do what you need

Mike
Reply With Quote
  #3 (permalink)  
Old 09-13-2005, 08:36 AM
WebProWorld Pro
 

Join Date: Jun 2004
Location: Weymouth, UK
Posts: 124
EmmaGale RepRank 0
Default Templates

Thank you for your reply.

Im using Dreamweaver templates and I cannot put an editable region around the body tag.

Is there anyway I can do this within the form within the head of the document?
Reply With Quote
  #4 (permalink)  
Old 09-13-2005, 09:08 AM
WebProWorld Pro
 

Join Date: Sep 2005
Location: Manchester, UK
Posts: 257
mikesmith76 RepRank 0
Default

you can place the following javascript in the page anywhere after the form

<script type="text/javascript">
<!--
document.form_name.field_name.focus();
-->
</script>

replacing form_name and field_name as appropriate. not the best solution but it should work. note it has to be after the form in the html, otherwise you will get javascript errors

hope this helps

mike
Reply With Quote
  #5 (permalink)  
Old 09-13-2005, 09:30 AM
WebProWorld Pro
 

Join Date: Jun 2004
Location: Weymouth, UK
Posts: 124
EmmaGale RepRank 0
Default BRILLIANTTTTTTT!

It works perfectly.

Thank you so much for your help.

Kind regards
Emma
Reply With Quote
  #6 (permalink)  
Old 09-13-2005, 10:49 AM
WebProWorld Pro
 

Join Date: Sep 2005
Location: Manchester, UK
Posts: 257
mikesmith76 RepRank 0
Default

no worries glad i could be of service
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Tags: , ,



Thread Tools
Display Modes

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

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


Search Engine Optimization by vBSEO 3.2.0