Skip to Content
author's profile photo
Former Member

Calling javascript within tableview model

Hi,

I am building a table using HTMLB. I need to call a javascript function within a <td>. The javascript formats the date. While adding to the Vector I add the cell content as

row.addElement("<script language=\"javascript\">dwColDateTime(new Date("date"));</script>");

Where date is a string.

In my JSP I have the following javascript function

<script language ="javascript">

function dwColDateTime(dt){

fdate = new Date(dt.getTime() + zonediff);

document.write(fdate);

}

</script>

When my table shows up, it shows the content of <td> as it is ie,

<script language="javascript">dwColDateTime(new Date(2004,2,19,08,45,0));</script>

Without HTMLB the javascript works fine.

How do I call the javascript function from within my cell in TableView?

Any ideas will be highly appreciated.

Thanks

lakshmi

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • author's profile photo
    Former Member
    Mar 22, 2004 at 11:22 AM

    I think the htmlb control escapes the html code you've added (don't know if there is any way to avoid this).

    If possible, it would be best to move the javascript code to the java dynpage code instead, avoid the problem alltogether

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Mar 23, 2004 at 05:00 PM

    Used encode() method to encode my Javascript before adding to the table and it worked fine.

    Lakshmi

    Add comment
    10|10000 characters needed characters exceeded