SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Wizard silver trophy someonewhois's Avatar
    Join Date
    Jan 2002
    Location
    Canada
    Posts
    6,364
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    What else should I learn?

    Ok, well, I know PHP fluently, and some basic JavaScript.

    I want to be more fluent. When working with form fields, and such, what would you reccomend? And with things, can you perhaps point out an example?

    You know, things like on mouse over (or onclick) in a form field, select all of what's already there, etc.

    Oh, and I was meaning to ask this, does this work on an <OPTION> tag in <SELECT>:

    Code:
    <select name="temp">
    <option value="test" onClick="location.href='myurl.html'">
    </select>
    ?

    I was meaning to know that

    I know teh basic onStuff, redirecting, variable uses etc.

    It's different cool things I'm not so good at




    Regards,
    Someonewhois

  2. #2
    SitePoint Enthusiast
    Join Date
    Dec 2002
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't believe it works on the <option> tag, but it works on the <select> tag.

    And just go search around for some JS tutorials if you want to learn, look at sites that use JS. I'm not the best, but I've learned quite a bit, mainly form manipulation, and pretty much all of it from that.
    -Mark

  3. #3
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,236
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    The option onclick won't work, but you can do something like this:
    Code:
    <select name="mySelect" onchange="yourFunction();">
    <option>Value 1</option>
    </select>
    I use it once in a while for jump menus and the like.

    Also, the best way to learn Javascript would be to read other sites' source code, go to places like http://www.dynamicdrive.com/, or just browse the forums!

    --Vinnie

  4. #4
    SitePoint Member
    Join Date
    Feb 2002
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello:
    The answers are all correct.
    The onclick event handler won't work on the <option>Value part.
    It has to be applied on the select tag.
    There are many ways of doing this.This is just an example:

    code:

    <html>
    <head>
    </head>
    <body>
    <div align="center">
    <form name="myform">
    <select name="test" size="1">
    <option value="http://www.sitepoint.com" SELECTED>SitePoint</option>
    <option value="http://www.yahoo.com">Yahoo</option>
    <option value="http://www.hotmail.com">Hotmail</option>
    </select>
    <input type="button" value="GO!"> onclick="window.location.href=document.myform.test.options[document.myform.test.selectedIndex].value">
    </form>
    </div>
    </body>
    </html>

    I hope this will be useful for you.

    Best Regards

    Alex

  5. #5
    SitePoint Wizard silver trophy someonewhois's Avatar
    Join Date
    Jan 2002
    Location
    Canada
    Posts
    6,364
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, but what else do you reccomend me learning to work with form fields etc.?

  6. #6
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,236
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Originally posted by someonewhois
    Ok, but what else do you reccomend me learning to work with form fields etc.?
    Validation. For starters, learn to validate your data with regular expressions. For example, all zip codes in the USA are five digits. You can use a regular expression to make sure that there are five numbers in there, and with RE you can do it in less lines of code rather than doing something like this:
    Code:
    if (document.form1.zipCode.value.length != 5) {
     //stuff, alert, whatever
    }
    if (isNaN(document.form1.zipCode.value)) {
     do your thing;
    }
    Here's a good place to start looking for regular expressions:
    http://www.regexplib.com/

    Hope this helps!

    --Vinnie


Bookmarks

Posting Permissions

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