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 7 of 7
  1. #1
    New Coder
    Join Date
    Nov 2007
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Write to TextArea

    edit: figured out the first part of this, still need help in second post.

    I am a complete novice with JavaScript and haven't even attempted anything in about a year. What I am trying I know I used to be able to do I just can not remember anything about it.

    I am just trying to make 2 drop downs. When you choose a one of the options, I want that option's value to appear in the text area below, then I want the text area to go to a new line for the next drop down's value.

    I apologize for being so noobish here. I am sure it will begin to come back to me the more I read. Its just easier for me to learn if I can see an example. I have done as much as I can remember. I am pretty sure i need to set IDs for my drop down form tag, but I can't remember for sure. Any help would be greatly appreciated.

    Code:
    <form>
    	<p><select size="1" name="vote1">
    	<option selected>-</option>
    	<option value="Vote1-1">1</option>
    	<option value="Vote1-2">2</option>
    	<option value="Vote1-3">3</option>
    	<option value="Vote1-4">4</option>
    	<option value="Vote1-5">5</option>
    	</select></p>
    
    
    	<p><select size="1" name="vote1">
    	<option selected>-</option>
    	<option value="Vote2-1">1</option>
    	<option value="Vote2-2">2</option>
    	<option value="Vote2-3">3</option>
    	<option value="Vote2-4">4</option>
    	<option value="Vote2-5">5</option>
    	</select></p>
    
    	<p><textarea rows="7" name="copy" cols="30"></textarea></p>
    </form>
    Last edited by rabit; 06-03-2009 at 05:29 PM.

  • #2
    New Coder
    Join Date
    Nov 2007
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ok I have this much..


    However, only problem I am having with this is that I don't want vote2 to overwrite vote1, in the text area. I want vote2's value to appear on a new line below vote1 in the text area.


    Code:
    <HEAD>
    <META http-equiv=Content-Type content="text/html">
    <SCRIPT language=javascript>
    function showValue(sel) {
    	var els = sel.form.elements;
    	els.copy.value = sel.value + "\n";
    	els = null;
    	sel = null;
    }
    
       </SCRIPT>
    <form>
    	<p>
    		<select size="1" name="vote1" onchange="showValue(this);">
    			<option selected>-</option>
    			<option value="Vote1-1">1</option>
    			<option value="Vote1-2">2</option>
    			<option value="Vote1-3">3</option>
    			<option value="Vote1-4">4</option>
    			<option value="Vote1-5">5</option>
    		</select>
    	</p>
    	<p>
    		<select size="1" name="vote1" onchange="showValue(this);">
    			<option selected>-</option>
    			<option value="Vote2-1">1</option>
    			<option value="Vote2-2">2</option>
    			<option value="Vote2-3">3</option>
    			<option value="Vote2-4">4</option>
    			<option value="Vote2-5">5</option>
    		</select>
    	</p>
    	<p><textarea rows="7" name="copy" cols="30"></textarea></p>
    </form>

  • #3
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,982
    Thanks
    203
    Thanked 2,536 Times in 2,514 Posts
    Like this?


    Code:
    <form name = "myform">
    	<p><select size="1" name="vote1" id = "vote1" onchange = "putInText(this)">
    	<option selected>-</option>
    	<option value="Vote1-1">1</option>
    	<option value="Vote1-2">2</option>
    	<option value="Vote1-3">3</option>
    	<option value="Vote1-4">4</option>
    	<option value="Vote1-5">5</option>
    	</select></p>
    
    	<p><select size="1" name="vote2" id = "vote2" onchange = "putInText(this)">
    	<option selected>-</option>
    	<option value="Vote2-1">1</option>
    	<option value="Vote2-2">2</option>
    	<option value="Vote2-3">3</option>
    	<option value="Vote2-4">4</option>
    	<option value="Vote2-5">5</option>
    	</select></p>
    
    	<p><textarea rows="7" name="copy" id = "copy"cols="30"></textarea></p>
    </form>
    
    <script type = "text/javascript">
    
    function putInText(which) {
    var a = which.value;
    var txt = document.getElementById("copy").value;
    document.getElementById("copy").value = txt + a + "\n";
    }
    
    </script>
    There is of course nothing to prevent the same selection being made twice.

    Why are you using several forms?

    <SCRIPT language=javascript> is lomg deprecated and obsolete. Use <script type = "text/javascript"> instead.


    Brevior saltare cum deformibus mulieribus est vita - Life is too short to dance with ugly women
    Last edited by Philip M; 06-03-2009 at 05:41 PM.

  • #4
    New Coder
    Join Date
    Nov 2007
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Exactly! its more complicated than I thought it had to be. I will comb it over and try to figure out how it works. I really appreciate the help, thank you!

  • #5
    New Coder
    Join Date
    Nov 2007
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Philip M View Post
    Why are you using several forms?
    Just 2. It has been a while since I have sought help and I wasn't sure what forum would be the best. Apparently they are both great. I didn't mean to clog either board up.

  • #6
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,982
    Thanks
    203
    Thanked 2,536 Times in 2,514 Posts
    Quote Originally Posted by rabit View Post
    Just 2. It has been a while since I have sought help and I wasn't sure what forum would be the best. Apparently they are both great. I didn't mean to clog either board up.
    I said FORMS not FORUMS!

    But cross or multiple posting is discouraged here.

  • #7
    New Coder
    Join Date
    Nov 2007
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Philip M View Post
    I said FORMS not FORUMS!

    But cross or multiple posting is discouarged here.
    Oh well, apparently I'm an idiot all around. Well either way I appreciate your help and look forward to learning more.


  •  

    Posting Permissions

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