473,395 Members | 1,631 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

code doesn't work!!

i wanted to print name which is given by user dynamically.
that is "myMother.firstname".but it does not work any more.please help me solve this.
Expand|Select|Wrap|Line Numbers
  1. <body>
  2. <p>heyy</p>
  3. First name:<input type="text" id="fname" onclick="callme()">
  4. <script type="text/javascript">
  5. <!--
  6.  
  7.     function person(firstname)
  8.       {
  9.           this.firstname=firstname;
  10.  
  11.       }
  12.  
  13.     function callme()
  14.     {
  15.         var n=document.getElementById("fname").value;
  16.         myMother=new person(n);
  17.     }
  18.      var d=document.getElementById("demo");
  19.      document.write("First name is:" +d.innerHTML=myMother.firstname);
  20. //-->
  21. </script>
  22. <p id="demo"></p>
  23. </body>
  24.  
Jul 21 '13 #1
7 1440
Dormilich
8,658 Expert Mod 8TB
document.write() is deleting your page (when used after the initial page load), including all scripts.
Jul 21 '13 #2
sorry,i cant get it what you trying to say.please elaborat.
Thank you.
Jul 21 '13 #3
okay i just edit my code.In that i remove document.write().
but still it has no effect on output!!!
Jul 21 '13 #4
Dormilich
8,658 Expert Mod 8TB
sorry,i cant get it what you trying to say
I said that document.write() erases your page (in the browser, not on the server, of course), it’s as simple as that.

but still it has no effect on output!!!
post the new code.
Jul 21 '13 #5
Expand|Select|Wrap|Line Numbers
  1. <p>heyy</p>
  2. First name:<input type="text" id="fname" onclick="callme()">
  3. <script type="text/javascript">
  4.  
  5.  
  6.     function person(firstname)
  7.       {
  8.           this.firstname=firstname;
  9.  
  10.       }
  11.  
  12.     function callme()
  13.     {
  14.         var n=document.getElementById("fname").value;
  15.         myMother=new person(n);
  16.     }
  17.      var d=document.getElementById("demo");
  18.      d.innerHTML=myMother.firstname;
  19.  
  20. </script>
  21. <p id="demo"></p>
  22. </body>
  23.  
Jul 21 '13 #6
function person(firstname)
this is called or not!
as there is no output on my browser!
Jul 21 '13 #7
Dormilich
8,658 Expert Mod 8TB
anything in the Error Console?
Jul 21 '13 #8

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

Similar topics

1
by: sachin bond | last post by:
The following code(in c++) is supposed to divide a file into 'n' different files. suppose i'm having a file called "input.zip". The execution of the following code should divide "input.zip"...
3
by: sachin bond | last post by:
this code does not work.... plz help...... void breaker() {
1
by: chris | last post by:
hi i am trying to make a vb.net control using Imports System.Web Dim email As New System.Web.Mail.MailMessage but it gives me the error Type 'System.Web.Mail.MailMessage' is not defined....
2
by: Rhys.Mataira | last post by:
My code will not show up anything at all on the screen can someone guide me why this would be? <?php $pagetitle="Login"; If (!$_POST) or (!$_POST) { echo" <head></head> <style...
4
by: raaman rai | last post by:
Hi guys, i installed WAMP Server 2 yesterday but i waz surprised to see that the following code doesnt work. Today is <? print strftime("%m/%d/%Y"); ?> The output is just: Today is ...
1
by: Dany13 | last post by:
hi all. i using some text box for input value and some localvarible for passing this data to dataset . give instance for correct row of dataset and data in data table . use one gird view for...
9
by: AGP | last post by:
I've been scratching my head for weeks to understand why some code doesnt work for me. here is what i have: dim sVal as string = "13.2401516" dim x as double x = sVal debug.writeline ( x)
2
Thew
by: Thew | last post by:
<script language="javascript" type="text/javascript"> function spoilershow(){ document.getElementById("spoiler").style.visibility='visible'; document.getElementById("show").value='close';...
0
by: xteaun | last post by:
Hi! I am trying to use the following code in a little VB.Net project and I just cant get it to work. I get an error that says the "adressof"-command isnt using the right delegate type and some...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.