Javascript error : HELP

Hi ,

Follow. is my javascript program. I'm getting an error

'e is undefined '

I'm not able to find it out . Could you please help me asap.

<html>

<head>

<script>

var a = 0;

var b = 0

f1(a,b);

function f1(c,d)

{

alert("f1");

var e = c;

var f = d;

document.write("<input type = button value = click onClick = 'f3(e,f)'>");

}

function f3(g,h)

{

var i = g;

var j = h;

alert("f3");

f1(i,j);

}

</script>

</head>

<body>

<form>

</form>

</html>

Thanks in advance.

-Priya

[743 byte] By [Priyam] at [2007-9-26 1:20:05]
# 1
well it is undefined right heredocument.write("<input type = button value = click onClick = 'f3(e,f)'>");you have to do this:onClick = 'f3(' + e + ',' + f + ')'>");play around with that you may need double quotes
JavaDen at 2007-6-29 0:53:39 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

Hi,

I tried in both the ways but now I'm getting Syntax error.

Could you please help me?

document.write('<input type = button value = click onClick = "f3(" + e + " , " + f + ")" >');

document.write("<input type = button value = click onClick = 'f3(' + e + ' , ' + f + ')' >");

Thanks,

-Priya

Priyam at 2007-6-29 0:53:39 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
document.write("<input type = button value = click onClick = 'f3(' + e + ' , ' + f + ')' >");use double quotes and escape them \"
JavaDen at 2007-6-29 0:53:39 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
Hi , document.write('<input type = button value = click onClick = \" f3( \" + e + \" , \" + f + \" ) \" >');I did like this but still getting the same Syntax error.I don't know what I am doing wrong .Thank you,-Priya
Priyam at 2007-6-29 0:53:39 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5
document.write('<input type = button value = click onClick = " \' f3( \' + e + \' , \' + f + \' ) \' ">');If I write like this again I'm getting an error ' e is undefined'
Priyam at 2007-6-29 0:53:39 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6
<% int e = 1; int f = 3;out.write("<input type='button' value ='click' onClick='f3(" + e + "," + f +")'>");%> this works
JavaDen at 2007-6-29 0:53:39 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 7
document.write("<input type='button' value ='click' onClick='f3(" + e + "," + f +")'>");in a html file i tried it out the values are 0,0<input type='button' value ='click' onClick='f3(0,0)'>
JavaDen at 2007-6-29 0:53:39 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 8
yes,its working nowthank you very much-Priya
Priyam at 2007-6-29 0:53:39 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 9

Hi JavaDen,

Follow. pgm works fine when I click that button first time. If i click button second time I'm getting 'Object not found' error.

<html>

<head>

<script>

var a = 0;

var b = 0

f1(a,b);

function f1(c,d)

{

var e = c;

var f = d;

document.write("<input type='button' value ='click' onClick='f3(" + e + "," + f +")'>");

}

function f3(g,h)

{

var i = g;

var j = h;

alert("f3");

f1(i,j);

}

</script>

</head>

<body>

<form name = frm>

</form>

</html>

thanks

Priyam at 2007-6-29 0:53:39 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 10

you cannot write the document.write("<input type='button' value ='click' onClick='f3(" + e + "," + f +")'>");

twice

you second function calls the first that writes the statement above and erases everything else

look at he source before and after you click on the button

what are you trying to do here?

JavaDen at 2007-6-29 0:53:39 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 11

Hi,

I saw the source code . It is erasing everything.

In my code I have one javascript function to populate array . It is displaying 5 rows. then I have 'Next' button in that function. which is calling other function to display next 5 rows . So I have to pass start & end values between these two functions. But I don't know how to do it.Can you please tell me how to do this?

I appreciate your help.

Thank you very much.

-Priya

Priyam at 2007-6-29 0:53:39 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 12
why do you need endvalues the endvalue is the startvalue + 5I need to see some code I don't know how you are displaying this
JavaDen at 2007-6-29 0:53:39 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 13

Hi,

I've follow .two functions. My array is having 30 elements. I want to populate 5 elements per page.I want to do it in javascript only.

Here is my code. Please let me know if i'm doing anything wrong.

thank you.

function printArray(mStartIndex,mEndIndex,mDataArray)

{

alert("pStartIndex = " + pStartIndex + "pEndIndex = "+ pEndIndex );

pStartIndex = mStartIndex;

pEndIndex = mEndIndex;

pDataArray = mDataArray;

document.writeln('<HTML>');

document.writeln('<TABLE BORDER = 1>');

for( var i = pStartIndex; (i < pEndIndex) && (i < pDataArray.length); i++)

{

document.writeln('<TR>');

document.writeln('<TD>');

document.writeln(pDataArray);

document.writeln('</TD>');

document.writeln('</TR>');

pStartIndex = i;

}

document.writeln('</TABLE>');

document.writeln('</HTML>');

if(pEndIndex >= pDataArray.length )

{

document.write("Next");

}

else

{

document.write("<input type = 'button' value = 'Next' onClick = 'nextRecords(" + pStartIndex + "," + pEndIndex +")'>");

}

if(pStartIndex <= 0)

{

document.write("Previous");

}

else

{

document.write('<input type = button value = Previous onClick = previousRecords()>');

}

}

function nextRecords(startIndex,endIndex)

{

alert(startIndex + " n, " + endIndex);

if (startIndex == 0)

{

}

if ((startIndex > 0) && (startIndex < xArray.length))

{

startIndex = endIndex;

endIndex = startIndex + pSize;

printArray(startIndex,endIndex,xArray);

}

}

-priya

Priyam at 2007-6-29 0:53:39 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...