473,666 Members | 2,480 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Javascript says "document.getEl ementById("name display") has no properties

11 New Member
I have this script
Expand|Select|Wrap|Line Numbers
  1. function getname(){
  2. <script type="text/javascript">
  3.     var name = prompt('What is your name?');
  4.     while(name==''){
  5.         name = prompt('We need your name?');
  6.     }
  7.     alert(name);
  8.     document.getElementById('namedisplay').value=name;
  9.  
  10. }
  11. getname();
  12. </script>
  13. <input name="namedisplay" type="text" id="namedisplay" value="" />
  14.  
When i run the script it works fine it asks for my name then alerts it back to me but when it is ment to put it into the display box it gets and error saying
"document.getEl ementById("name display") has no properties"
i am stumped

Can you please help

Thanks Scott
Nov 15 '07 #1
2 2011
mrhoo
428 Contributor
you are assigning a value to an element that has not been introduced yet. Move the script, or assign the value when the document has loaded.

onload=function (){document.get ElementById('na medisplay').val ue=name};
Nov 15 '07 #2
Fisher ma
9 New Member
You can put the input element before javascript code.

Expand|Select|Wrap|Line Numbers
  1. <input name="namedisplay" type="text" id="namedisplay" value="" />
  2.  
  3. <script type="text/javascript">
  4. function getname(){
  5.     var name = prompt('What is your name?');
  6.     while(name==''){
  7.         name = prompt('We need your name?');
  8.     }
  9.     alert(name);
  10.     document.getElementById('namedisplay').value=name; 
  11. }
  12. getname();
  13. </script>
  14.  
Nov 16 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

10
2558
by: AnnMarie | last post by:
What is the best editor to use for JavaScript?
3
1946
by: Plamen Valtchev | last post by:
This is my problem: From JavaScript I want to find the list of all defined/loaded JavaScript functions/objects/names within the current scope (html page in a browser). the page could contain many included javascript with the script tag : <script language="javascript" src="XXX/Script.js"></script>
1
6806
by: ido | last post by:
Hi all this is my first post here :) I would like to know something about using javascript programaticaly The thing is i have this web site on which when i press a button i uses a function of javascript.. says exactly this in source <a href="javascript:np('1')" ... now when i am on that page and i type in my browsers comand line (o address field)
1
970
by: msdn | last post by:
I know this is not a JavaScript group. Direct me to the right place if you get offended Question: Does anyone know exactly what does code below mean or do. var AZ = Function.AZ = function(someVar){...} Thanks,
1
1360
by: awebguynow | last post by:
I'm actually trying to analyze the Google Suggest code as dissected by C. Justus, eyalamir, alacrity and others. This could be a follow-up to my unanswered posting: Topic: "Google Suggest, advanced JS, DHTML" other keywords: okuh But my ? this time is specific: Can properties of Objects be created on the fly ? Can they be user-defined (UD) and brought into existence, just by an assignment ?
1
1040
by: Stu | last post by:
Hi, id like to update a literal using javascript in my aspx code i have a literal with a span tag as follows: <td class="mainTitle" style="height:40;"> <asp:Literal ID="litLink" runat="server" Text=""><span id="spanAdvert"></span></asp:Literal>
5
5895
by: =?Utf-8?B?QVRT?= | last post by:
PRB JavaScript in ASP with Request.Form Please help, I'm having a problem with JavaScript in ASP, where the ASP page crashes when I try to determine if data was posted from a FORM or through a QueryString. Where, if the data came through via a FORM, I want to use it 1st, but if not, to then try using it from the QueryString. Basically, the problem boils down to using "toString()" on Request.Form("NAME") and Request.QueryString("NAME")...
2
1221
by: V Rajagopalan | last post by:
can anyone help me to know the syntax being used in javascript and its functions,Properties. For example, when we write code like "text1" followed by "dot" in VB lt display some properties like that Is there any tutorial for Javascript ? I am trying to incorporate Javascript in my Asp.net Application. Thanks & Regards V.Rajagopalan
2
4990
by: NitinSawant | last post by:
Hello, I'm beginner to actionscript, I've defined following function in script tag of page <script type="text/javascript"> function showMessage(){ alert("javascript says: Hello ActionScript"); } </script> i want to call it from actionscript,
0
8454
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8362
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8878
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8785
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8560
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5671
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4372
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2012
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1778
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.