Re: javascript quickie - SOLVED

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wednesday 26 November 2008 12:59:46 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     

-- 
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines

[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux