User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 391,604 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,630 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 801 | Replies: 4 | Solved
Reply
Join Date: Apr 2008
Posts: 17
Reputation: vanessia_1999 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
vanessia_1999 vanessia_1999 is offline Offline
Newbie Poster

displaying text name in text box

  #1  
May 20th, 2008
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.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Apr 2008
Posts: 43
Reputation: Daedal is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 11
Daedal's Avatar
Daedal Daedal is offline Offline
Light Poster

Re: displaying text name in text box

  #2  
May 20th, 2008
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>
Reply With Quote  
Join Date: Apr 2008
Posts: 17
Reputation: vanessia_1999 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
vanessia_1999 vanessia_1999 is offline Offline
Newbie Poster

Re: displaying text name in text box

  #3  
May 20th, 2008
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.
Reply With Quote  
Join Date: Apr 2008
Posts: 43
Reputation: Daedal is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 11
Daedal's Avatar
Daedal Daedal is offline Offline
Light Poster

Re: displaying text name in text box

  #4  
May 20th, 2008
If you want that variable to be "refreshed" every time you call that function, then place it in the function. Solved?
Reply With Quote  
Join Date: Apr 2008
Posts: 17
Reputation: vanessia_1999 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
vanessia_1999 vanessia_1999 is offline Offline
Newbie Poster

Re: displaying text name in text box

  #5  
May 20th, 2008
Solve, and totatlly understand. Thank you very much.

Originally Posted by Daedal View Post
If you want that variable to be "refreshed" every time you call that function, then place it in the function. Solved?
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb JavaScript / DHTML / AJAX Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 12:01 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC