0

Hi all,

I'm down with a question. How do i add in a javascript function into another function? For eg. I have a button that enable me to create a new table on the page. when the table is created, there is input of text with calendar function. Is it possible to do so?

Greatly appreciated for your help.

3
Contributors
6
Replies
10
Views
7 Years
Discussion Span
Last Post by lf.gene
0

Depends on how you add it. If you add it as innerHTML and compose function calls with text, you could do that. If you add it with element creation, you could do it too but would be a little bit different way of adding function call to the page. It would be better to have function definition in an external javascript file and include the source at the top of the page, so you can call it whenever and wherever you want in the page.

Edited by Taywin: n/a

0

function insCell()
{
var x=document.getElementById('tr2').insertCell(1);
var y=document.getElementById('tr1').insertCell(1);
y.innerHTML= 'Day 1';
x.innerHTML='<input type = "text" name = "day">onmouseover="if (timeoutId) clearTimeout(timeoutId);window.status='Show Calendar';return true;" onmouseout="if (timeoutDelay) calendarTimeout();window.status='';" onclick="g_Calendar.show(event,'frm.day',true,'yyyy-mm-dd'); return false;"><img src="images/calendar.gif" name="imgCalendar" width="34" height="21" border="0" alt="">';
}

Here the code that i having problems with. I was thinking is there a need to append for that sentence in red and how can i append?

0

Arranging your code:

function insCell()
{
    var x=document.getElementById('tr2').insertCell(1);
    var y=document.getElementById('tr1').insertCell(1);
    y.innerHTML= 'Day 1';
    x.innerHTML='<input type="text" name="day" onmouseover="onOver();" onmouseout="onOut();" onclick="onClick();"><img src="images/calendar.gif" name="imgCalendar" width="34" height="21" border="0" alt="">';
}
function onOver() {
    if (timeoutId) clearTimeout(timeoutId);
    window.status='Show Calendar';
    return true;
}

function onOut() {
    if (timeoutDelay) calendarTimeout();
    window.status='';
    return true;
}

function onClick() {
    g_Calendar.show(event,'frm.day',true,'yyyy-mm-dd'); 
    return false;
}

There were typos.

Edited by Luckychap: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.