Hi I am new to javascript .. I am trying to break a query up into three sections and display the results when the output equals the number assigned.. I do not know what am I doing incorrectlt... Please see code below:
Thanks
Shan
Code:
<html>
<head>
<script type="text/javascript" src="/soap/ajax/10.0/connection.js"></script>
<script type="text/javascript">
window.onload=init_page;
function init_page()
{
var j= "";
var output="";
strSQL="Select Id,AS400_Account_Number__c,Name,BillingCity,SF_DATE_ON_SERVICE__c,SF_DATE_OFF_SERVICE__c,SF_OFF_SERVICE_DESC__c from Account " +
strSQL = strSQL + "where OwnerId='00550000000mLCX'" +
if (output==1)
{
alert("bbb");
strSQL=strSQL + "and SF_DATE_ON_SERVICE__c = LAST_N_DAYS:30";
else (output==2)
strSQL=strSQL + "and SF_OFF_SERVICE_CODE__c<>'9' and SF_DATE_OFF_SERVICE__c = LAST_N_DAYS:30";
else (output==3)
strSQL = strSQL + "and SF_OFF_SERVICE_CODE__c='9' and SF_DATE_OFF_SERVICE__c = LAST_N_DAYS:30";
}
//SF_DATE_ON_SERVICE__c = LAST_N_DAYS:30and SF_OFF_SERVICE_CODE__c<>'9' and SF_DATE_OFF_SERVICE__c = LAST_N_DAYS:30";
var result = sforce.connection.query(strSQL);
var records = result.getArray("records");
output==1; //<over here I state the first output should display the query should be the entire strsql plus the where clause assigned
for (var i=0; i<records.length; i++)
{
j += '<a href="/' + records[i].Id + ' "target=_blank"">' + <note sfid= {records[i].Id}><id>{i+1}</id><date>{records[i].SF_DATE_ON_SERVICE__c}</date><acct>{records[i].AS400_Account_Number__c}</acct><name>{records[i].Name}</name><city>{records[i].BillingCity}</city></note> + '</a><br>';
}
document.getElementById('div_tag').innerHTML = j;
}
}
</script>
</head>
<body bgcolor="#F3F3EC">
<font size="2" face="Verdana">
<div id="div_tag">No Accts</div>
</font>
</body>
</html>
Shan