Padrill
07-23-2003, 08:21 AM
Hi all,
I have a drop down menu a few times in a web site and thought to make it in a reusable script and not manually type the whole code each time. However I need to add drop down menus dynamically and the following doesn't work (I guess the script code is added but not executed - makes sense). Can anyone suggest any solutions?
function dropDownDay(strName) {
document.write('<select name="' + strName + '">');
for (i=1; i<=31; i++) {
document.write('<option value="' + i +'">' + i + '</option>');
}
document.write('</select>');
return true;
}
function addMenu(span) {
span.innerHTML = '<script>dropDownDay("myDay")</scr'+'ipt>';
}
----------------------------
<span name="dyn" id="dyn"></span>
<input type="button" onMouseUp="addMenu(dyn)">
I have a drop down menu a few times in a web site and thought to make it in a reusable script and not manually type the whole code each time. However I need to add drop down menus dynamically and the following doesn't work (I guess the script code is added but not executed - makes sense). Can anyone suggest any solutions?
function dropDownDay(strName) {
document.write('<select name="' + strName + '">');
for (i=1; i<=31; i++) {
document.write('<option value="' + i +'">' + i + '</option>');
}
document.write('</select>');
return true;
}
function addMenu(span) {
span.innerHTML = '<script>dropDownDay("myDay")</scr'+'ipt>';
}
----------------------------
<span name="dyn" id="dyn"></span>
<input type="button" onMouseUp="addMenu(dyn)">