submit form with dynamic number fo fields
Posted: Fri Jun 11, 2004 1:59 pm
I have a form that needs a to show only a certain number fo fields based another value in the form. I wrote a javascript function to add the rows to the table that I need and then populate the cells with input fields. Here is the javascript function:
I am calling the function from another text box using the onBlur event. Like so
I am not having a problem with the extra form fields being created on the page. The problem is that when I submit the form none of the fields added by my javascript function are shown. if I do a print_r($_POST) it lists all the fields excpet for the ones added after the page was loaded. Any ideas would be great. I would give a linkt o the page but it's on an internal only webserver.
PS This is my first big jump into using Javascript on my web apps so don't assume I know what I'm doing.
Thanks
Code: Select all
function drawMembers(totalMembers)
{
// Get the number of rows already shown for the hhmembers
var shown = document.getElementById('membersTable').rows.length;
for (i = shown; i <= totalMembers; i++) {
var tbl = document.getElementById('membersTable').insertRow(shown);
var cell1 = tbl.insertCell(0);
cell1.className = 'form-display';
cell1.innerHTML = '<input type="text" name="hhmembersї]їlast]" size="13" value="" onFocus="window.status=''Enter the Household Members Last Name'';style.backgroundColor=''#E9F8E2'';" onBlur="style.backgroundColor=''#ffffff'';window.status='''';" />';
}
}Code: Select all
onBlur="drawMembers(parent.document.intake.hhnum.value);"PS This is my first big jump into using Javascript on my web apps so don't assume I know what I'm doing.
Thanks