using prompt and textarea

trying to figure out how to put the the input from the prompt into a t

Page 1 of 1

1 Replies - 6731 Views - Last Post: 25 February 2009 - 04:19 PM

#1 mweaver84  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 06-December 08

using prompt and textarea

Post icon  Posted 25 February 2009 - 02:07 PM

I know I have alot to add to this(/head, /body, etc) but am messing around with this assignment right now and can't figure something out. I am suppose to be able to hit the prompt button and the input from the user in prompt window is suppose to print out in the textarea in the bottom... have looked on the internet for a few hours and can't figure out how to do it =( The teacher set most of the code up for us (have done part of the assignment on it already) but am stuck on this part. any help is much appreciated


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
		"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script type="text/javascript"> 
function show_prompt() { 
var my_string = prompt("Please enter your name","enter your first name only");

}
</script>



<button id="alert" name="" value="Hello World" type="button" onclick="alert( document.getElementById('alert').value );">
		Alert Button 
	</button>
	<button id="fakebutton" type="button"  onclick="show_prompt()">
		Prompt Button 
	</button>

	<button name="tb" type="button">
		Toggle Button 
	</button>
	<button name="b" type="button">
		Bigger 
	</button>
	<button name="s" type="button">
		Smaller 
	</button>
	<button name="c" type="button">

		Cycle 
	</button>
	<button name="r" type="button">
		Read
	</button>
	<p id="green">
		Forms do not have to send anything, you can use a form simply to place form boxes. This way the validators shut up and you can more easily refer to them in javascript. The 
		<b>
			document 
		</b>
		object contains an array of 
		<b>

			form 
		</b>
		objects, you can either get them by number document.forms[0] or, you can get them by the form's name (name attribute of the form tag) document.formname. In the form object, there is another array called 
		<b>
			elements 
		</b>
		which contains all form-related html tags within that form (form.elements[]). Just like with form, you can also use the name used in the attribute to refer to elements. (form.inputname) 
		<b>
			NOTE: 
		</b>
		the name attributes are case-sensitive 
	</p>

	<form action="java script:alert('hello');" method="get">
		<p>
		<textarea id="textOutput" name="textOutput" rows="4" cols="80">
		</textarea>
		</p>
	</form>




Is This A Good Question/Topic? 0
  • +

Replies To: using prompt and textarea

#2 BetaWar  Icon User is offline

  • #include "soul.h"
  • member icon

Reputation: 1201
  • View blog
  • Posts: 7,309
  • Joined: 07-September 06

Re: using prompt and textarea

Posted 25 February 2009 - 04:19 PM

Try changing this:
function show_prompt() { 
var my_string = prompt("Please enter your name","enter your first name only");

}



to this:
function show_prompt(){
  var my_string = prompt("Please enter your name","enter your first name only");
  document.getElementById("textOutput").value = my_string;
}


I haven't tried it out with your script, but it should work, unless there is another problem in it, that I didn't see.

HTH
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1