SitePoint Sponsor

User Tag List

Results 1 to 10 of 10

Thread: form

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Dec 2001
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    form

    something screwed is happening with my form.
    I'm <i>trying</i> to make a SELECT with urls in and when the user clicks on on it, it automatically changes the url. Here's what I've got :

    <form name="formOne">
    <select name="siteSelect" class="forms" onChange="reDirect(document.formOne.siteSelect.value);">
    <option selected value="0">-= Pick From List =-
    <option selected value="http://www.url1.com">URL 1
    ...
    ...
    ...
    </select>

    function reDirect(p){

    if( p != 0 ){
    window.location = p;
    }
    }

    I thought that would work, but it doesn't return the value from the select, it just says that its null or not an object.

  2. #2
    The Legend Indian's Avatar
    Join Date
    Nov 2001
    Location
    Gods' Own Country
    Posts
    890
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    It is working!

    <form name="formOne">
    <select name="siteSelect" class="forms" onChange="reDirect(document.formOne.siteSelect.value);">
    <option selected value="0">-= Pick From List =-
    <option value="http://www.url1.com">URL 1
    ...
    ...
    ...
    </select>
    <script>
    function reDirect(p){

    if( p != 0 ){
    window.location = p;
    }
    }
    </script>

  3. #3
    SitePoint Enthusiast
    Join Date
    Dec 2001
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I left the script tags out to save space in the post
    in any case, the script is in a linked .js file

  4. #4
    The Legend Indian's Avatar
    Join Date
    Nov 2001
    Location
    Gods' Own Country
    Posts
    890
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Anyway, there is nothing wrong with your script.

  5. #5
    SitePoint Enthusiast
    Join Date
    Dec 2001
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you would think that wouldn't you but I've spent the past two days trying to sort it and it doesn't want to work.
    it just keeps telling me the value from the SELECT is null or not an object... which I can't understand cuz I've used it many times before and it worked... but I've never used the onChange before now... I dunno... its broken...

    any other suggestions would be appreciated.
    Last edited by DarknessAwaits; Dec 16, 2001 at 13:00.

  6. #6
    SitePoint Enthusiast
    Join Date
    Dec 2001
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    well I've sorted 1/2 of the problem. The FORM is in a DIV and when I deleted the DIV it worked fine... so that just leaves one problem, how do I call the SELECT value from a FORM in a DIV ??

  7. #7
    SitePoint Guru Vincent Puglia's Avatar
    Join Date
    Feb 2000
    Location
    where the World once stood
    Posts
    700
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi darknessAwaits,

    You will find the following scripts/tutorials (both at my site) informative:
    1) Select & Go Menus
    2) Hiding Options

    Vinny
    Where the World Once Stood
    the blades of grass
    cut me still

  8. #8
    SitePoint Enthusiast
    Join Date
    Dec 2001
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    d'oh, I had made the most stupid mistake... I had left a " off the end of a style in the DIV... all sorted now tho

  9. #9
    Prolific Blogger silver trophy Technosailor's Avatar
    Join Date
    Jun 2001
    Location
    Before These Crowded Streets
    Posts
    9,446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'd think that the DOM method also for the form in a div would be as such:
    Code:
    document.DIVname.formOne.siteSelect.value
    Sketch
    Aaron Brazell
    Technosailor



  10. #10
    SitePoint Enthusiast
    Join Date
    Dec 2001
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    as it turned out its was normal, every day, good 'ol:

    window.formName.selectName.value

    but my mistake messed it up bad style.


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
  •