Jump to content

Dynamically populate text area?


Recommended Posts

Im not sure if this is in the correct board so apologies,

 

Ive been having trouble trying to insert multiple values into 1 field, my way around it, and a more aesthetically pleasing look, is to have to boxes, an empty one and 1 with a list of predefined variables, I want to click one of the variables for it to then shoot across to the other text area, pouplating it on each click, does this make sense?

Link to comment
Share on other sites

Ive come accross this which does exactly as I need, only it doesnt populate more than 1 value. Im a complete amateur with javascript so if anybody could pooint me in the right direction id be so greatful :)

 

<form name="form1">
<select
style="background-color: transparent; font-size: 10px; color: rgb(0, 102, 153); font-family: verdana;"
name="menu">
<option value="#">Quick Links ...</option>
<option value="This is for value no.1">Value No. 1</option>
<option value="This is for value no.2">Value No. 2</option>
<option value="This is for value no.3">Value No. 3</option>
<option value="This is for value no.4">Value No. 4</option>
<option value="This is for value no.5">Value No. 5</option>
<option value="This is for value no.6">Value No. 6</option>
</select>
<input
style="font-size: 8pt; color: rgb(255, 255, 255); font-family: verdana; background-color: rgb(0, 102, 153);"
value="Populate" type="button" onClick="document.form1.accept.value=document.form1.menu.options[document.form1.menu.selectedIndex].value;document.form1.textareaaccept.value=document.form1.menu.options[document.form1.menu.selectedIndex].value;">
<br/>
<br/>
<textarea type="text" name="accept" style="width:200px;"></textarea>
<br/>

</form>

Link to comment
Share on other sites

liamloveslearning,

 

See if the following does what you want.

 

Let us know.

 


<?php

Header("Cache-control: private, no-cache");
Header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
Header("Pragma: no-cache");

?>

<html>

<head>

<script type="text/javascript">

function addText() {

	if (document.form1.menu.options[document.form1.menu.selectedIndex].value != '#') { // Don't write "Quick Links" to text area...

		//    Magic Happens with the "+=" operator
		document.form1.accept.value += document.form1.menu.options[document.form1.menu.selectedIndex].value + "\n";

		alert(document.form1.accept.value);

		// document.form1.textarea.accept.value=document.form1.menu.options[document.form1.menu.selectedIndex].value;

	}

}

</script>

</head>

<body>

<form name="form1">

<select onChange="addText();" style="background-color: transparent; font-size: 10px; color: rgb(0, 102, 153); font-family: verdana;"name="menu">
	<option id="val[]" name="val[]" value="#">Quick Links ...</option>
	<option id="val[]" name="val[]" value="This is for value no.1">Value No. 1</option>
	<option id="val[]" name="val[]" value="This is for value no.2">Value No. 2</option>
	<option id="val[]" name="val[]" value="This is for value no.3">Value No. 3</option>
	<option id="val[]" name="val[]" value="This is for value no.4">Value No. 4</option>
	<option id="val[]" name="val[]" value="This is for value no.5">Value No. 5</option>
	<option id="val[]" name="val[]" value="This is for value no.6">Value No. 6</option>
</select>

<span width="50px;"> Text -> </span>

<textarea type="text" id="accept" name="accept" style="width:275px; height:175px;"></textarea>

<br/>

</form>

</body>

</html>

 

Hope it helps.

 

Scot L. Diddle, Richmond VA

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.