www.webdeveloper.com
Recent Articles
  • Finding Slow Running Queries in ASE 15
  • A More Advanced Pie Chart for Analysis Services Data
  • Adobe AIR Programming Unleashed: Working with Windows
  • Performance Testing SQL Server 2008's Change Data Capture Functionality
  • The ABC's of PHP: Introduction to PHP
  • How to Migrate from BasicFiles to SecureFiles Storage
  • Why the Twitter Haters Are Wrong
  • User Personalization with PHP: Beginning the Application
  • Whats in an Oracle Schema?
  • Lighting Enhancement in Photoshop
  •  

    Go Back   WebDeveloper.com > Client-Side Development > HTML

    HTML Discussion and technical support for building, using and deploying HTML sites.

    Reply
     
    Thread Tools Rate Thread Display Modes
      #1  
    Old 02-08-2010, 06:58 PM
    dkperez dkperez is offline
    Registered User
     
    Join Date: Jan 2010
    Posts: 24
    Setting focus to field on tabular form

    I have an html form with several columns. The rows of data are created in php and sent to the form. Each column is an array. How do I set the focus to a specific data cell?

    I know about the javascript to setfocus on the body tag, but how do I have it set the focus to a particular cell of an array?

    Last edited by dkperez; 02-08-2010 at 07:01 PM.
    Reply With Quote
      #2  
    Old 02-09-2010, 01:08 AM
    Fang's Avatar
    Fang Fang is offline
    Resistance is futile
     
    Join Date: Apr 2003
    Location: Netherlands
    Posts: 20,058
    With html use a bookmark: url#elementID
    Javascript offers more options depending on when the focus is required and the type of element.
    __________________
    At least 98% of internet users' DNA is identical to that of chimpanzees
    Reply With Quote
      #3  
    Old 02-09-2010, 09:29 AM
    dkperez dkperez is offline
    Registered User
     
    Join Date: Jan 2010
    Posts: 24
    I got the initial focus to set on the body tag using this:

    <body OnLoad="document.salonentry.Title0.focus();">

    But, when the user hits the button to display a new row (empty, for entering a new record), how do I change the focus so when we come back from the php and display the data, how do I put the focus in the first field of the new row, which is a select list?
    Reply With Quote
      #4  
    Old 02-09-2010, 10:33 AM
    Fang's Avatar
    Fang Fang is offline
    Resistance is futile
     
    Join Date: Apr 2003
    Location: Netherlands
    Posts: 20,058
    Quote:
    when we come back from the php and display the data
    How are you doing this? Form submission or Ajax?
    __________________
    At least 98% of internet users' DNA is identical to that of chimpanzees
    Reply With Quote
      #5  
    Old 02-09-2010, 11:14 AM
    dkperez dkperez is offline
    Registered User
     
    Join Date: Jan 2010
    Posts: 24
    It's not Ajax, so I'm presuming it's form submission. I'm using POST in the form definition.
    Reply With Quote
      #6  
    Old 02-09-2010, 12:45 PM
    Fang's Avatar
    Fang Fang is offline
    Resistance is futile
     
    Join Date: Apr 2003
    Location: Netherlands
    Posts: 20,058
    This would focus on the last input element:
    Code:
    window.onload=function() {
    var aObj = document.getElementsByTagName('input');
    aObj[aObj.length-1].focus();
    };
    __________________
    At least 98% of internet users' DNA is identical to that of chimpanzees
    Reply With Quote
    Reply

    Bookmarks


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

    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
    Forum Jump


    All times are GMT -5. The time now is 01:13 PM.



    Acceptable Use Policy

    Internet.com
    The Network for Technology Professionals

    Search:

    About Internet.com

    Legal Notices, Licensing, Permissions, Privacy Policy.
    Advertise | Newsletters | E-mail Offers

    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.