[Wylug-help] javascript quickie - SOLVED
Gary Stainburn
gary.stainburn at ringways.co.uk
Wed Nov 26 13:53:45 UTC 2008
On Wednesday 26 November 2008 12:07:16 Gary Stainburn wrote:
> Hi folks.
>
> I've got the following HTML which works:
>
> <td
> id="td_pdi_23096"
> bgcolor=#ff9999
> title="Click to set"
> onclick="GooleSetPDI(23096,'t');return false;"
>
> P.D.I.<br>Pinnacle not raised
> </td>
>
> GooleSetPDI is called, the AJAX function runs and the the response is
> received.
>
> Then, in the respose javascript I have:
>
> var TD=document.getElementById('td_pdi_'+response[1]);
> if (TD) {
> if (response[2] == 't') {
> TD.style.backgroundColor='#99ff99';
> TD.innerHTML='P.D.I.<br>Pinnacle raised';
> TD.onclick="GooleSetPDI("+response[1]+",'f');return false;";
> } else {
> TD.style.backgroundColor='#ff9999';
> TD.innerHTML='P.D.I.<br>Pinnacle not raised';
> TD.onclick="GooleSetPDI("+response[1]+",'t');return false;";
> }
> }
> else
> alert("The records were updated, but an error occured updating the
> screen");
>
> The TD changes colour, the TD content changes, but the onclick stops
> working.
>
> Anyone know what stupid mistake I've made?
Aparently, the problem is with having parameters. I got round this by using
eval() based on a solution found at
http://www.webdeveloper.com/forum/archive/index.php/t-33159.html
The solution is:
TD.onclick=function(){eval("GooleSetPDI("+response[1]+",'t')");};
--
Gary Stainburn
This email does not contain private or confidential material as it
may be snooped on by interested government parties for unknown
and undisclosed purposes - Regulation of Investigatory Powers Act, 2000
More information about the Wylug-help
mailing list