PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Fri Nov 21, 2014 5:22 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Fri Jun 11, 2004 1:59 pm 
Offline
Forum Contributor

Joined: Tue Aug 27, 2002 8:50 am
Posts: 108
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:
Syntax: [ Download ] [ Hide ]
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='''';" />';
        }
}


I am calling the function from another text box using the onBlur event. Like so
Syntax: [ Download ] [ Hide ]
onBlur="drawMembers(parent.document.intake.hhnum.value);"


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


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 11, 2004 3:58 pm 
Offline
Forum Regular
User avatar

Joined: Fri May 09, 2003 11:53 pm
Posts: 589
Location: Belo Horizonte, Brazil
Hello kcomer, nice trick!

I got it working, tale a look: http://scorphus.no-ip.com/lab/dynamic_form.php

Scorphus.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 14, 2004 9:00 am 
Offline
Forum Contributor

Joined: Tue Aug 27, 2002 8:50 am
Posts: 108
I still can't get mine to work. I installed the Web Developer tools for Firefox wich let me see the form details. When I look at your form and update the field number it shows the added fields when I use the "View Form Information" from the Web Developer toolbar. When I try mine, it doesn't. Has anyone seen this behavior before? I tried your page on ym dev server and it worked fine so I know it's not my server or my client. It's acting like the form fields that I'm adding are being added after the </form> because they don't appear.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 14, 2004 9:15 am 
Offline
Forum Contributor

Joined: Tue Aug 27, 2002 8:50 am
Posts: 108
Followup:

I had a table nested within a table, like so.
Syntax: [ Download ] [ Hide ]
&lt;form&gt;
&lt;table&gt;
&lt;tr&gt;
        &lt;td&gt;
                &lt;table&gt;
                &lt;tr&gt;
                        &lt;td&gt;&lt;/td&gt;
                &lt;/tr&gt;
                &lt;/table&gt;
        &lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/form&gt;

When I moved the form tags inside the table it worked fine, like this.
Syntax: [ Download ] [ Hide ]
&lt;table&gt;
&lt;tr&gt;
        &lt;td&gt;
                &lt;form&gt;
                &lt;table&gt;
                &lt;tr&gt;
                        &lt;td&gt;&lt;/td&gt;
                &lt;/tr&gt;
                &lt;/table&gt;
                &lt;/form&gt;
        &lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;

Thanks for the help though. I atleast knew I had the right code, I may try this with IE and Safari later to see if it's a bug with Firefox or maybe just an html issue.

Thanks again.

Keith


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group