Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / HTML, CSS, Scripts / JavaScript / November 2006



Tip: Looking for answers? Try searching our database.

NaN  error

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
sangram - 30 Nov 2006 07:14 GMT
i am calling these functions bellow while adding and deleting ,i am
getting NaN on html page.

i need early replay...
thanks
sangram

var dual=0;
function check1()
{
       deleteRow(dual);
       dual=0;
       return true;
}

function check()
{

       generateRow(dual);
       dual=1;
       return true;

}

function deleteRow(dual)
{
       if(dual == 1)
       {
               var d1=document.getElementById("san1");
               d1.innerHTML-="<lable>Company Name*</label>";
               var d=document.getElementById("san");
               d.innerHTML-="<input type='text' name='company' >";
       }
       return true;
}

function generateRow(dual)
{
       if(dual < 1)
       {
               var d1=document.getElementById("san1");
               d1.innerHTML+="<lable>Company Name*</label>";
               var d=document.getElementById("san");
               d.innerHTML+="<input type='text' name='company'>";
       }
       return true;

}

it returns NaN on the broweser..
i do not want to display that one...
web.dev - 30 Nov 2006 08:19 GMT
> i am calling these functions bellow while adding and deleting ,i am
> getting NaN on html page.

[snip]

> it returns NaN on the broweser..
> i do not want to display that one...

None of the functions you've shown are relevant to the error you're
seeing.  NaN stands for "Not a Number".  I'm assuming you're doing a
mathematical operation somewhere but I cannot tell with the code you've
presented.  Try to give a minimal example of which the error still
reproduces.
sangram - 30 Nov 2006 11:31 GMT
> > i am calling these functions bellow while adding and deleting ,i am
> > getting NaN on html page.
[quoted text clipped - 9 lines]
> presented.  Try to give a minimal example of which the error still
> reproduces.

i am calling this add function on onclick event of one radio button and
deleting in another radio button..
Fred - 30 Nov 2006 08:45 GMT
> i am calling these functions bellow while adding and deleting ,i am
> getting NaN on html page.
>
> i need early replay...

Then play it again...  :-)

[...]
> function deleteRow(dual)
> {
[quoted text clipped - 4 lines]
>                 var d=document.getElementById("san");
>                 d.innerHTML-="<input type='text' name='company' >";

While the + operator is overloaded to do both arithmetic addition and
string concatentation (and unary plus), the - operator is not similarly
overloaded: it works only as arithmetic subraction, not a kind of
replace operator.  The variables being operated on must be numbers, not
strings.

You might also want to correct the "lable" tag name typo.

[...]

Signature

Fred

sangram - 30 Nov 2006 11:32 GMT
> > i am calling these functions bellow while adding and deleting ,i am
> > getting NaN on html page.
[quoted text clipped - 25 lines]
> --
> Fred

Thanks friend..
then how to do this..
how to delete the added text box.
Fred - 30 Nov 2006 12:41 GMT
> > > i am calling these functions bellow while adding and deleting ,i am
> > > getting NaN on html page.
[quoted text clipped - 25 lines]
> > --
> > Fred
[...]
> how to delete the added text box.

Use DOM methods.  innerHTML is a kludge, but also very convenient.  If
you want to remove all the content of the table cell, the simplest
method is to set its innerHTML to an empty string.

A more elegant method is to remove all its child nodes:

 while (d1.firstChild) {
   d1.removeChild(d1.firstChild);
 }

If you want to remove particular nodes, you may need to use other
methods.  It is impossible to recommend a suitable method without
understanding what you are trying to do or seeing the HTML you are
working on.

Signature

Fred

Dr J R Stockton - 30 Nov 2006 22:53 GMT
In comp.lang.javascript message
<1164876312.866310.100960@j72g2000cwa.googlegroups.com>, Thu, 30 Nov

>While the + operator is overloaded to do both arithmetic addition and
>string concatentation (and unary plus), the - operator is not similarly
>overloaded: it works only as arithmetic subraction,

There, "only" is not *quite* true.  Unary minus changes sign, but does
not subtract.

> not a kind of
>replace operator.

Signature

 (c) John Stockton, Surrey, UK.  ?@merlyn.demon.co.uk   Turnpike v6.05   MIME.
 Web  <URL:http://www.merlyn.demon.co.uk/> - FAQqish topics, acronyms & links;
  Astro stuff via astron-1.htm, gravity0.htm ; quotings.htm, pascal.htm, etc.
 No Encoding. Quotes before replies. Snip well. Write clearly. Don't Mail News.

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.