•
•
•
•
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
![]() |
•
•
Join Date: Apr 2008
Posts: 17
Reputation:
Rep Power: 1
Solved Threads: 0
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.
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.
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>•
•
Join Date: Apr 2008
Posts: 17
Reputation:
Rep Power: 1
Solved Threads: 0
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.
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?
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb JavaScript / DHTML / AJAX Marketplace
Similar Threads
- A multilingual coded Hello World! thread (Legacy and Other Languages)
- Re: Basic Sorted Neighborhood in VB (VB.NET)
- Homework: filling array from text file (VB.NET)
- WIN32 GUI application - Problem popping up dialog box (C++)
- shutdown pc from dos prompt (Windows tips 'n' tweaks)
- PLS Help newbie (Java)
- Looking for List Box help, please! (VB.NET)
- "sponsored link" box too small for mozilla (DaniWeb Community Feedback)
- Displaying pictures on Windows Forms using subprocedures in VB.NET (VB.NET)
- IE6 - Not displaying background colours... (Web Browsers)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: how to make div id's unique
- Next Thread: Make columns equal height with Javascript


Linear Mode