dcsimg
www.webdeveloper.com
Page 1 of 3 123 LastLast
Results 1 to 15 of 37

Thread: Id Focus

  1. #1
    Join Date
    Oct 2003
    Location
    Pensacola, Fl
    Posts
    149

    Id Focus

    Howdy lads 'n lassies,

    I'd like to use an id name in an if() parameter if I can determine that it is being focused on. Soooooooooo, I'm wondering how to do this! ha ha. For example:

    //[code]

    if(is this_id being focused on?) {
    do this;
    } else {
    do that;
    }

    //[code]


    Thanx for any suggestions

  2. #2
    Join Date
    Sep 2003
    Location
    Portsmouth, UK Occupation: Web Developer
    Posts
    2,602
    you could try, instead of what you are trying to do

    if(is this_id being focused on?) {
    do this;
    } else {
    do that;
    }

    <input type="text" name="tb1" value="Test" size="12" />

    this

    <input type="text" name="tb1" value="Test" onfocus="alert('Oi, Get The Cursor Out Of Here');" onblur="alert('Hey, Why You Click Off Me');" size="12" />

  3. #3
    Join Date
    Oct 2003
    Location
    Pensacola, Fl
    Posts
    149
    g r i n - -well, that works in its own way, 96. I'm working on a cascade menu, though, so I need an if/else statement with a focus evaluation. Any further suggestions quite welcome, however!

  4. #4
    Join Date
    Sep 2003
    Location
    Portsmouth, UK Occupation: Web Developer
    Posts
    2,602
    what about onmouseover and onmouseout

    eg

    <img src="google.gif" alt="Logo" width="78" height="56" title="Logo" onmouseover="alert('Hello');" onmouseout="alert('Goodbye');" />

  5. #5
    Join Date
    Oct 2003
    Location
    Pensacola, Fl
    Posts
    149
    Basically I have to work with script and an if/else statement, 96, cuz I've got to have a loop in a for() statement to hide all contingent <div>s. There are probably easier ways to make a cascade menu, but I'm sort of learning on-the-fly, you know. Most books are inaccurate, and most code I've found on the net so far is pretty cryptic and difficult. I'll just keep searching, and hope I come across something. Feel free to continue making any suggestions!

  6. #6
    Join Date
    Sep 2003
    Location
    Portsmouth, UK Occupation: Web Developer
    Posts
    2,602
    ok so couldnt you apply the onmouseover to the divs eg

    Home | Page 1 | Page 2 | Page 3

    | are spaces between the divs, if you applied on mouseover and out to home div which calls function eg on mouseover="show(home);" mouseout="hide(home);"

    if thats not it im sorry, but im loosing the plot , can you post your entrie code

    Rich

  7. #7
    Join Date
    Oct 2003
    Location
    Pensacola, Fl
    Posts
    149
    I may be working with a limitation I set by using a combined function for hiding and showing, Rich. Let me experiment with a simplified version like your suggestion and see what I can come up with. Get back to ya later - -

  8. #8
    Join Date
    Oct 2003
    Location
    Pensacola, Fl
    Posts
    149
    I looked at doing this with onMouseOver(), but there's the same limitation. - - hmmm... if you like to take a look at it, I'll attach the .htm file. It's pretty short, and the javascript is at the bottom. Thanx for your input, Rich.

  9. #9
    Join Date
    Oct 2003
    Location
    Pensacola, Fl
    Posts
    149
    ...oops, forgot to attach my file. Here it is, for anybody that wants to look at it...
    Attached Files Attached Files

  10. #10
    Join Date
    Dec 2002
    Location
    Manchester, UK
    Posts
    6,276
    Here are two menus that I just wrote now. One is a CSS menu (much more accessible and cleaner code), the other is a DHTML menu that uses the DOM.

    There are some styles common to both to provide a bit of a layout structure, you can replace those styles with some of your own (or tables if you must ).

    Basically the DHTML is doing the same as the CSS but in a much less accessible and more long winded way.

    Edited to correct HTML, missed off a </ul>.
    Attached Files Attached Files
    Last edited by David Harrison; 06-02-2004 at 08:37 PM.
    Every fight is a food fight when you’re a cannibal.

  11. #11
    Join Date
    Oct 2003
    Location
    Pensacola, Fl
    Posts
    149
    thanx lava, I'll take a look at your code. Afraid I don't have much knowledge on CSS...well, actually, none at all! I'd like to learn it, but I'm on a pretty steep curve trying to develop a page as I go. I'll drop a line after I look at your examples.

  12. #12
    Join Date
    Dec 2002
    Location
    Manchester, UK
    Posts
    6,276
    Just bear in mind that at first the CSS will look more complicated that it actually is because it's mixed in with other CSS.
    Also, the DHTML will look more complicated because you probably won't have seen code like that before but it's also quite simple.

    Here they are again but reduced to just the bare bones:

    Edited to correct HTML, missed off a </ul>.

    I just thought I'd say that I've left in a few selectors with no styles in them so you can see where the styles used to be, they serve no purpose really.
    Attached Files Attached Files
    Last edited by David Harrison; 06-02-2004 at 08:36 PM.
    Every fight is a food fight when you’re a cannibal.

  13. #13
    Join Date
    Oct 2003
    Location
    Pensacola, Fl
    Posts
    149
    *wow*. The CSS was amazingly simple. True, I haven't seen that code before, but I was able to ascertain generally what happens with it. I think I'll go to the bookstore this afternoon and look for a book on CSS. I sort of cringe to spend the money on it, because you know how the book thing goes. I usually end up just gleaning some general ideas out of them that are useful, and the rest generally gets wasted. Well, sure blows the javascript out of the water on that count.

  14. #14
    Join Date
    Dec 2002
    Location
    Manchester, UK
    Posts
    6,276
    I can recommend a good book for XHTML and CSS, it's called:

    Elizabeth Castrow's HTML for the World Wide Web 5th Edition with XHTML and CSS.

    I got it a while ago but it's still very good, it goes through pretty much everything and there's an excellent reference guid in the back for XHTML elements and CSS properties. There may be another version out by now, I don't know.
    Every fight is a food fight when you’re a cannibal.

  15. #15
    Join Date
    Oct 2003
    Location
    Pensacola, Fl
    Posts
    149
    Went and looked at books at the store today, but only found one on CSS, and it didn't looked all that great. I made a note of the one you suggested, and I'll look it up. I've also been toying with that script you made, tried nesting a new <ul> to make successive levels other than the first two. Haven't been successful yet, though.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles