Click to See Complete Forum and Search --> : Problem in my JS function


prabhukm
09-17-2003, 12:32 AM
Hi All,

I am having a fcunction which will submit a form with some values. Actually this function is properly working in Mozilla, IE 6. But in Opera and IE 5.0, the function is not working. My function is

function doSorting(isAscending,orderByColumn)
{
if(orderByColumn != document.pagexform.orderByColumn.value )
{
document.pagexform.isAscending.value = "true";
document.pagexform.orderByColumn.value = orderByColumn;
}
else
{
if(isAscending == "true")
{
isAscending="false";
}
else if(isAscending == "false")
{
isAscending="true";
}
document.pagexform.isAscending.value = isAscending;
document.pagexform.orderByColumn.value = orderByColumn;

}
document.pagexform.FROM_INDEX.value="1";
document.pagexform.TO_INDEX.value = parseInt(document.pagexform.FROM_INDEX.value) + parseInt(document.pagexform.viewLength.value)-1;
document.pagexform.PAGE_NUMBER.value="1";
document.pagexform.submit();
}


If i include a alert() means, that function is properly working.

So please help me to find where i'm making the mistake.

Thanks in Advance,
Prabhu

Fang
09-17-2003, 04:51 AM
Is your function being passed boolean or string values?
isAscending == "true" string compare?

prabhukm
09-17-2003, 11:25 PM
Dear Fang,

We believe that there is no issue in the String check. The incoming variable is a string only.
All the statements in the function (except form.submit) is working properly. If i include a alert() message or another submit(), the form is being submitted.

Thanks,
Prabhu

Fang
09-18-2003, 01:43 AM
I tried it out with Opera 6 and 7 without a problem.
There are a few logic errors in your function:
isAscending is checked against "true" and "false", but if another value is entered no change will be made.
This: document.pagexform.TO_INDEX.value = parseInt(document.pagexform.FROM_INDEX.value) + parseInt(document.pagexform.viewLength.value)-1;

can be written as document.pagexform.TO_INDEX.value = parseInt(document.pagexform.viewLength.value)

Apart from the above you need to look at the input values, their range and boolean/string type.