SuperSal
Programmer
- Mar 13, 2007
- 33
Hi everyone, ok this is a bit strange the way its been done so bare with me! I am dynamically creating menu items and need to create a save function to save the values of form items on the server only I cannot seem to access the values of the dynamically created form items and I'm not sure why. The code is as follows:
this.SysName = new create_menu( "SysName"); //general
this.SysName.description = "System Name";
this.SysName.var_type = "Alpha";
this.SysName.size = 40;
this.SysName.readonly = false;
this.SysName.value = "DM00D0D9181716";
this.SysName.onchange = true;
function render_alpha(menu_desc)
{
var dstr="";
dstr += '<tr><td>' + menu_desc.description +'</td><td></td>\n';
dstr += '<td align=center><input type="text" size=' + menu_desc.size +' value="' + menu_desc.value +'" id=name_'+ menu_desc.sys_var +'" name="name_'+ menu_desc.sys_var +'"';
if (menu_desc.readonly)
dstr += "READONLY";
dstr += '></td></tr>\n';
return dstr;
}
function render_multi_menu(menu_desc)
{
var dstr="";
for (var iter in menu_desc)
{
if (menu_desc[iter].var_type == "Alpha")
dstr += render_alpha(menu_desc[iter]);
if (menu_desc[iter].var_type == "Checkbox")
dstr += render_checkbox(menu_desc[iter]);
if (menu_desc[iter].var_type == "Numeric")
dstr += render_numeric(menu_desc[iter]);
if (menu_desc[iter].var_type == "Combo")
dstr += render_combo(menu_desc[iter]);
if (menu_desc[iter].onchange == true)
save_settings(menu_desc[iter]);
}
return dstr;
}
function render_table(title)
{
var dstr="";
var i;
dstr += '<form action="">\n';
dstr += '<table>\n';
dstr += '<tr><td></td><td><FONT SIZE=+1 FACE="Arial"><b>' + title + '</b></font></td></tr>\n';
dstr += render_multi_menu(general);
dstr += '<tr><td> </td><td> </td><td> </td></tr>\n';
dstr += '</table>\n';
dstr += '</form>\n';
return (dstr);
}
var general = new menu_list();
document.write(render_table("Test Table"));
function get_formdata()
{
var data = document.name_SysName.value; //this not getting the value
alert(data);
I am running the get_formdata() function from the onUnload method.
Thanks
Sally
this.SysName = new create_menu( "SysName"); //general
this.SysName.description = "System Name";
this.SysName.var_type = "Alpha";
this.SysName.size = 40;
this.SysName.readonly = false;
this.SysName.value = "DM00D0D9181716";
this.SysName.onchange = true;
function render_alpha(menu_desc)
{
var dstr="";
dstr += '<tr><td>' + menu_desc.description +'</td><td></td>\n';
dstr += '<td align=center><input type="text" size=' + menu_desc.size +' value="' + menu_desc.value +'" id=name_'+ menu_desc.sys_var +'" name="name_'+ menu_desc.sys_var +'"';
if (menu_desc.readonly)
dstr += "READONLY";
dstr += '></td></tr>\n';
return dstr;
}
function render_multi_menu(menu_desc)
{
var dstr="";
for (var iter in menu_desc)
{
if (menu_desc[iter].var_type == "Alpha")
dstr += render_alpha(menu_desc[iter]);
if (menu_desc[iter].var_type == "Checkbox")
dstr += render_checkbox(menu_desc[iter]);
if (menu_desc[iter].var_type == "Numeric")
dstr += render_numeric(menu_desc[iter]);
if (menu_desc[iter].var_type == "Combo")
dstr += render_combo(menu_desc[iter]);
if (menu_desc[iter].onchange == true)
save_settings(menu_desc[iter]);
}
return dstr;
}
function render_table(title)
{
var dstr="";
var i;
dstr += '<form action="">\n';
dstr += '<table>\n';
dstr += '<tr><td></td><td><FONT SIZE=+1 FACE="Arial"><b>' + title + '</b></font></td></tr>\n';
dstr += render_multi_menu(general);
dstr += '<tr><td> </td><td> </td><td> </td></tr>\n';
dstr += '</table>\n';
dstr += '</form>\n';
return (dstr);
}
var general = new menu_list();
document.write(render_table("Test Table"));
function get_formdata()
{
var data = document.name_SysName.value; //this not getting the value
alert(data);
I am running the get_formdata() function from the onUnload method.
Thanks
Sally