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 4 of 4
  1. #1
    New Coder
    Join Date
    Aug 2010
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Need assistance in Selection Box

    i have a selection menu here. what i would like to do is that when i select "not copy" it will not show and not copy the contents of "todo" textfield. but when i select any of the "copy text" it will show and copy the contents of the "todo" text. help plsssssssssssssssssss


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>

    </head>

    <body>
    <form id="form" name="form" method="post" action="">
    <p>Phone Number:
    <input type="text" name="Name" />
    </p>
    <p>Location:
    <select name="selector" >
    <option>copy text</option>
    <option>not copy text</option>
    <option>copy text</option>
    <option>copy text</option>
    </select>
    </p>
    <p>To Do Today:
    <input type="text" name="todo" />
    </p>
    <p>
    <input type="button" value="Copy" />
    </p>
    </form>
    </body>
    </html>

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,303
    Thanks
    203
    Thanked 2,562 Times in 2,540 Posts
    Copy to where? The clipboard? A <div> on the same page? A pop-up? Another page?

    What is the point of having several identical options <option>copy text</option>?

    To capture the value of a selected option:-

    optionValue = document.form.selector.value

    But you have not assigned any values to the options. And it is a bad idea to name your form "form".


    It is not as cold as it was yesterday, but that's probably because it's a bit warmer. - BBC Scotland News.

  • #3
    New Coder
    Join Date
    Aug 2010
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts
    this is just an example of what i am working on. it will copy to the text area in another frame. parent.mainFrame.textArea.value

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>

    </head>

    <body>
    <form id="form" name="form1" method="post" action="">
    <p>Phone Number:
    <input type="text" id="Name" name="Name" />
    </p>
    <p>Location:
    <select name="selector" id="selector" >
    <option>copy text</option>
    <option>not copy text</option>
    <option>copy text</option>
    <option>copy text</option>
    </select>
    </p>
    <p>To Do Today:
    <input type="text" id="todo"name="todo" />
    </p>
    <p>
    <input type="button" id="mybutton" value="Copy" />
    </p>
    </form>
    </body>
    </html>

  • #4
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,303
    Thanks
    203
    Thanked 2,562 Times in 2,540 Posts
    <input type="text" id="Name" name="Name" />
    Although Name and name are not the same (Javscript is case sensitive) it is still a bad idea.
    And why is a field supposed to be a phone number given the name "Name"?

    I still do not understand why several options are the same.
    You need to assign values to your options:-

    Code:
    <select name="selector" id="selector" >
    <option value = 1>copy text</option>
    <option value = 2>not copy text</option>
    <option value = 3>copy text</option>
    <option value = 4>copy text</option>
    </select>
    Then in script:-
    Code:
    var op = document.form1.selector.value;
    if ((op == 1) || (op == 3) || (op == 4)) {
    parent.mainFrame.textArea.value = document.form1.todo.value;
    }

    BTW, when posting here please follow the posting guidelines and wrap your code in CODE tags. This means use the octothorpe or # button on the toolbar. You can (and should) edit your previous post.
    Last edited by Philip M; 09-11-2010 at 07:56 PM. Reason: Typo


  •  

    Posting Permissions

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