Hi, I have a little problem. It is almost working but it continue to say undefine in the text area instead of the name they type in the txt box. I might be confusing you so i am going to put down what I have then explain what I am trying to do.

var txtaReceipt;
var txtName;
var txtName=document.write.frmMain.txtaReceipt.value("");  

function ProcessOrder()
{
document.frmMain.txtaReceipt.value=("Welcome to Dirty Deli," + txtName + "!");
{
alert("hi"); <!--I am only using the alert to let me know that the page is really working, that is how I check that the page is functioning-->
}

<form name=frmMain>
  	<strong>Customer's Name:</strong>
  	<input name="txtName" type="text" />

	<p></p>

	<input type="button" value="Process Order" onclick="ProcessOrder()" />

	<br />

   	<textarea name="txtaReceipt" rows="10" cols="40">
	</textarea>

</form>
}

What I am trying to do is when a person put in their name in the txtName box it will show in the txtaReceipt box within my greeting tag.

my problem is that it is not working it continue to say undefine. So I am thinking the variable is undefine or something wrong with it but I dont know how to fix it. Can someone help me please.

Try this:

<script type="text/javascript">
var txtaReceipt;
var txtName;

function ProcessOrder()
{
var txtName=document.frmMain.txtName.value;  
document.frmMain.txtaReceipt.value=("Welcome to Dirty Deli," + txtName + "!");
alert("hi"); <!--I am only using the alert to let me know that the page is really working, that is how I check that the page is functioning-->
}
</script>
<form name=frmMain>
  	<strong>Customer's Name:</strong>
  	<input name="txtName" type="text" />

	<p></p>

	<input type="button" value="Process Order" onclick="ProcessOrder()" />

	<br />

   	<textarea name="txtaReceipt" rows="10" cols="40">
	</textarea>

</form>
commented: Good work +8

oh my goodness get out of here. That was all that was needed. Thank you very much!

May I ask one question though. I would I know for future purpose to write the define variable in my function instead of the top with the variables.

I am a begginner so please excuse my ignorance. I am trying to learn and understand javascript.

If you want that variable to be "refreshed" every time you call that function, then place it in the function. Solved?

Solve, and totatlly understand. Thank you very much.

If you want that variable to be "refreshed" every time you call that function, then place it in the function. Solved?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.