Problem with output templates which are calling 3 services

hi there,
i hva written a service which is assigned an output template and
within that template am using javascript and calling 3 services
based upon browser inputs,if you see the below code
ie when i submit the form its executing the first/third conditions
and returning the result which i dont want at one time only one
condtion must be executed.pls find the code

Search

function test()
{
alert(“in third servc”);

%invoke eBankReports.SearchCentral:paymentMsgSearchResults%
%end%
}

function chkValue()
{

alert(“in script”);
one = document.form1.seqNo.value;
two = document.form1.transRefNo.value;

alert(two.length);
alert(one.length);

if((one.length == 0) && (two.length != 0))
{
alert(“executed service”);
%invoke eBankReports.SearchCentral:paymentMsgSearchResultTransNo%

%end%
}
else if((one.length != 0) && (two.length == 0))
{
alert(“executed second service”);

%invoke eBankReports.SearchCentral:paymentMsgSearchResultsSeqNo%
%end%
}

else if((one.length == 0) && (two.length == 0))
{
eBankReports.SearchCentral:paymentMsgSearchResults%

}
}

Search

Payment Message Search

  

Sequence Number
Transaction Number
Company Code
Received Date
Status Code
Error Code
Ebank Error Code–>

%value STATUS_MESSAGE%

%ifvar includeResults equals(‘Yes’)%

Sequence Number
Transaction Ref
Company Code
Transaction Data
Transaction Comment
Tag 32
Debit Account
Received Date
Status Code
Status Message
Error Code
Error Msg
EBank Error Code–>
Error Msg–>

%loop struct results%

%value SEQUENCE_NUMBER%
%value TRANSACTION_REF_NO%
%value COMPANY_CODE%
%value TRANSACTION_DATA%
%value TRANSACTION_COMMENT%
%value TAG32%
%value DEBIT_ACCOUNT%
%value REC_DATE%
%value STATUS_CODE%
%value STATUS_MESSAGE%
%value ERROR_CODE%
%value ERROR_MESSAGE%
%value EBANK_ERROR_CODE%
%value ERROR_MESSAGE%–>

%end%

 

the value of index from transno srvc is %value index%
%ifvar index equals(‘15’)%
%else%

%end%

%end%