Gail Kasnett
12/09/2020, 10:43 AMmsg +=
"<p><b><a id='book' onClick='"+ bookRate(rate.id, shipmentID)+"' >Select This Rate</a></b></p>"
The above is running the function when building the string
The below is telling me that bookRate is not defined.
msg +=
"<p><b><a id='book' onClick='bookRate(rate.id, shipmentID)' >Select This Rate</a></b></p>"
Whats the best way to go about this?battk
12/09/2020, 10:52 AMbattk
12/09/2020, 10:53 AMbattk
12/09/2020, 10:55 AMbattk
12/09/2020, 10:57 AMbattk
12/09/2020, 10:58 AMGail Kasnett
12/09/2020, 11:01 AMGail Kasnett
12/09/2020, 11:01 AMbattk
12/09/2020, 11:05 AMGail Kasnett
12/09/2020, 7:45 PMbattk
12/09/2020, 7:48 PMbattk
12/09/2020, 7:49 PMGail Kasnett
12/09/2020, 9:18 PMbattk
12/09/2020, 9:34 PMbattk
12/09/2020, 9:35 PMdocument.getElementById('book')
works be identifiying html elements by idbattk
12/09/2020, 9:35 PMbattk
12/09/2020, 9:37 PM.click
is not the name of the onclick event handlerbattk
12/09/2020, 9:38 PMbattk
12/09/2020, 9:39 PMbookRate(rate.id, shipmentID)
will not return a functionbattk
12/09/2020, 9:41 PMbattk
12/09/2020, 9:41 PMbattk
12/09/2020, 9:45 PMbattk
12/09/2020, 9:55 PMbattk
12/09/2020, 9:56 PMbattk
12/09/2020, 10:09 PMbattk
12/09/2020, 10:18 PMvar a = 1;
var b = 2;
document.getElementById("book").onclick = function () {
console.log(a + b);
};
would log 3 when the link is pressed because the onclick function still has access to a and b through its closure