By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,729 Members | 1,490 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,729 IT Pros & Developers. It's quick & easy.

NaN error

P: n/a
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...

Nov 30 '06 #1
Share this Question
Share on Google+
6 Replies


P: n/a

sangram wrote:
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.

Nov 30 '06 #2

P: n/a

sangram wrote:
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)
{
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' >";
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.

[...]

--
Fred

Nov 30 '06 #3

P: n/a

web.dev wrote:
sangram wrote:
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.
i am calling this add function on onclick event of one radio button and
deleting in another radio button..

Nov 30 '06 #4

P: n/a

Fred wrote:
sangram wrote:
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)
{
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' >";

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.

[...]

--
Fred
Thanks friend..
then how to do this..
how to delete the added text box.

Nov 30 '06 #5

P: n/a
sangram wrote:
Fred wrote:
sangram wrote:
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)
{
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' >";
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.

[...]

--
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.
--
Fred

Nov 30 '06 #6

P: n/a
In comp.lang.javascript message
<11**********************@j72g2000cwa.googlegroups .com>, Thu, 30 Nov
2006 00:45:12, Fred <oz****@iinet.net.auwrote:
>
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.

--
(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.
Nov 30 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.