SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    May 2004
    Location
    USA
    Posts
    0
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Choosing submit button with javascript

    I have a form with the following drop down

    Code:
     <select name="option" onChange="nav(this);">
     <option value="">----------------</option>
     <option value="copyfile">Copy</option>
     <option value="renamefile">Rename</option>
     ......yadda yadda.....
     </select>

    Im wanting a certain submit a certain input button (I have several different ones in one form) depending on which drop down item they select.

    So if they select Copy. I would want the javascript function to basically act like <input type="submit" name="copyfile" /> was clicked, and similarly if Rename was clicked, I would like it to act as if <input type="submit" name="rename" /> was submitted.

    Thanks,
    gex6

  2. #2
    SitePoint Wizard
    Join Date
    Mar 2004
    Posts
    1,647
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    function nav(obj) {
    switch(obj.options[obj.selectedIndex].value == "bla") {
    case "bla": alert("bla"); break;
    case "blabla": alert("blabla"); break,
    }
    }
    cheers


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
  •