You need to sign in to do that
Don't have an account?

PLEASE HELP!!!!!!!!!!!!!
Hello - Please help to fix my syntax problem here, I need to get the contact in function cm(contact)...
Please see in red:
==============================================
<html>
<head>
<script src="/soap/ajax/9.0/connection.js"></script>
<script src="https://www.salesforce.com/services/lib/ajax/beta3.3/sforceclient.js" type="text/javascript"></script>
<script language="javascript">
var fn = "cm(this)";
function do_code()
{
//////////////////////////////////////
var cust_name = '{!Account.Name}';
var qrdr5 = sforce.connection.query("Select c.Id from Account c where c.Name= '" + cust_name + "'");
var records = qrdr5.getArray("records");
for (var x = 0; x < records.length; x++)
{
tt5 = records[x];
var ttt = tt5.get("Id");
}
/////////////////////////////////////
var qrdr2 = sforce.connection.query("Select Name from Contact c where AccountId= '" + ttt + "'order by createdDate");
var records = qrdr2.getArray("records");
document.write("<b><u>Please Select Customer Contact:</u></b><BR><BR>");
document.write("<HR>");
for (var y = 0; y < records.length; y++)
{
tt2 = records[y];
var t=tt2.get("Name");
document.write("<BR>");
output = "<input id=btn1 type=button name=btn1 onclick=cm(obj); value='" + t + "'>";
document.write(output);
document.write("<BR>");
}
document.write("<BR>");
document.write("<HR>");
}
////////////////////////////////////
function cm(contact) {
alert(contact);
}
<head>
<script src="/soap/ajax/9.0/connection.js"></script>
<script src="https://www.salesforce.com/services/lib/ajax/beta3.3/sforceclient.js" type="text/javascript"></script>
<script language="javascript">
var fn = "cm(this)";
function do_code()
{
//////////////////////////////////////
var cust_name = '{!Account.Name}';
var qrdr5 = sforce.connection.query("Select c.Id from Account c where c.Name= '" + cust_name + "'");
var records = qrdr5.getArray("records");
for (var x = 0; x < records.length; x++)
{
tt5 = records[x];
var ttt = tt5.get("Id");
}
/////////////////////////////////////
var qrdr2 = sforce.connection.query("Select Name from Contact c where AccountId= '" + ttt + "'order by createdDate");
var records = qrdr2.getArray("records");
document.write("<b><u>Please Select Customer Contact:</u></b><BR><BR>");
document.write("<HR>");
for (var y = 0; y < records.length; y++)
{
tt2 = records[y];
var t=tt2.get("Name");
document.write("<BR>");
output = "<input id=btn1 type=button name=btn1 onclick=cm(obj); value='" + t + "'>";
document.write(output);
document.write("<BR>");
}
document.write("<BR>");
document.write("<HR>");
}
////////////////////////////////////
function cm(contact) {
alert(contact);
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Customer Contacts...</title>
</head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Customer Contacts...</title>
</head>
<body onLoad="do_code();">
</body>
</html>
</body>
</html>
output = "<input id=btn1 type=button name=btn1 onclick=cm(obj); value='" + t + "'>";
To
output = "<input id=btn1 type=button name=btn1 onclick=cm('" + t + '"); value='" + t + "'>";
Or
var con = t + " " + tt2.[fieldNames]
output = "<input id=btn1 type=button name=btn1 onclick=cm('" + con + '"); value='" + t + "'>";
hope this helps
Unfortunatelly it didn't work...
I am still waiting for some sugestions.
1. Screaming "PLEASE HELP!!!!!" in your subject line makes me think you've got an urgent problem instead of some lame javascript issue.
If you actually *have* an urgent problem then I respect you for the urgency. But, when you've just got some sample code that you can't get to work and you're screaming for help, it makes me think you're just clueless.
2. Second pointing out that you're still waiting for suggestions on a public discussion board after you've already received one in just two hours is also kind of goofy. The world does not flock to help you solve your problems. You might say thanks to the guy who essentially gave you the right answer.
3. Provide some more data if the first suggestion didn't help. Provide data as to *why* the suggestion didn't help? Did you look at the generated Javascript? What does it look like? What behavior *do* you get? Did you Google "onclick Javascript" to see what others do?
Best of luck. Steve.
p.s. Lastly, you should combine your two queries into one for speed. Consider using error handling.