#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Posts
    15
    Rep Power
    0

    Javascript and Forms... help!!!


    I don't really know how to describe this, because I don't know what methods it requires.



    What I'm trying to do is have a container within a page, and when someone clicks the "Add" button a set of drop down menus would show up in the container. When they click "Delete," the last set of drop downs would disappear. Because they may need to do this serveral times, the page itself cannot be refreshed, but only the things within the container.

    When the user is done they would press "Save" and the information would be sent to the server.

    Can someone point me to some resources for this? I'm sure there's some examples of things similar to this but I've looked and looked on Google and I'm ready to rip my hair out. Thanks!
  2. #2
  3. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    147
    Rep Power
    12
    Sounds like you could do that with a few onClick events and some hidden elements. I'm not sure exactly what you're after, but I can show you how to hide and show an element on the page (in this case a drop down box).

    If initally you do not want your select box displayed, you will need to set this style for it:
    PHP Code:
    <select style="display: none;"
    You will also need to give it an id reference:
    PHP Code:
    <select id="my_select" style="display: none;"
    Next, you will want to create your button (link) to activate the select box. this will include the javascript event onClick which will pass the id of your select box to a function which will be created shortly
    PHP Code:
    <a href="javascript:show('my_select')">show</a
    This function show() should take the id of a select box and set it to display as inline:
    PHP Code:
    function show(id) {
         
    document.getElementById(id).style.display 'inline';

    And now your select box should be visible. You can modify the show() function to also accept the id of the the link which called it. From there you can alter the href of your link to call another function hide() which would reverse the show() function and set the display value back to 'none'. This would let you click the same link to hide that you clicked to show the box. The javascript syntax for changing an href value looks like this:
    PHP Code:
    document.getElementById(id).href 'new_url'
    Hope that helps, if not, it's still a useful feature. The website in my sig has a working model of this using hidden <div>s but is currently down due to server issues.
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Posts
    15
    Rep Power
    0
    ctstone,

    Thanks! That gets the ball rolling quite nicely

    Is there a way to have drop down menus in a container? That way, if there are a lot of them they'll throw in a scroll bar and what not. Please see the picture below to see what I mean:



    TIA!
  6. #4
  7. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    147
    Rep Power
    12
    the only way i can think of is to use an iframe.
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Posts
    15
    Rep Power
    0
    I don't know if iframes will be able to do this, because the user will be able to add or delete rows as they go along.

    Is there any sort of Container object that's similar to the one used in Java applets?
  10. #6
  11. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Posts
    15
    Rep Power
    0
    I think I found a way around the container!

    I'm going to put all of them into a table.... but is there a way to make the table a certain vertical size, past which it will begin to scroll?
    Last edited by Edox; July 29th, 2003 at 04:40 PM.
  12. #7
  13. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    147
    Rep Power
    12
    i found this

IMN logo majestic logo threadwatch logo seochat tools logo