Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Aug 2002
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Changing From Button Use To Drop Down Menu

    Hi,

    Here is my current bit of javascript;

    PHP Code:
    <script>
    function 
    jsin(element) {
            
    document.theform.page.value document.theform.page.value "\n element "; }
    </script>

    <form name="theform" action="file.htm" method=POST>
    Click to insert:
    <input type="button" value="Name"
    onClick="jsin(Name);">
    <input type="button" value="Age"
    onClick="jsin(Age);">
    ....
    ...
    </form> 
    That provides the user with boxes, and when they click on the box, the appropriate field gets put into the form.

    My question is..
    Instead of using boxes, how can I make a drop down menu that when the user clicks onto the appropriate field, it'll add it to the form?
    Basically, I want to change the buttons for a drop down menu.

    Can anyone please help me out here?

    TX!!!

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    The Planet Earth Code Poet: True
    Posts
    282
    Thanks
    0
    Thanked 1 Time in 1 Post
    How about something like this:

    <script>
    function jsin(element) {
    document.theform.page.value += "\n"+ element ; }
    </script>

    <form name="theform" action="file.htm" method=POST>
    <select name="choices" onchange="if(this.selectedIndex!=0)jsin(this.options[this.selectedIndex].text)">
    <option>Choose to insert</option>
    <option>Name</option>
    <option>Age</option>
    </select>
    <textarea cols="30" rows="10" name="page"></textarea>
    </form>

  • #3
    New to the CF scene
    Join Date
    Aug 2002
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Great!! Thank you soooo much!

  • #4
    New to the CF scene
    Join Date
    Aug 2002
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    One more question.

    Right now, this only enters the text, not the value of the option.

    IE; If my form has this;

    <option value="Thank you for contacting our company!">Thank You</option>

    It'll only add the words 'Thank You' to the form, and not the entire value. Is there a way to change that?

    Thanks!

  • #5
    Regular Coder
    Join Date
    Jul 2002
    Location
    Western US
    Posts
    169
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That will require only one change...

    <select name="choices" onchange="if(this.selectedIndex!=0)jsin(this.options[this.selectedIndex].value)">

    You want the value, of the option. Text is what is displayed.

    ShriekForth

  • #6
    New to the CF scene
    Join Date
    Aug 2002
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Much obliged!

    Thanks


  •  

    Posting Permissions

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