View Single Post
Old 01-06-2009, 11:09 PM   #4 (permalink)
Salathe
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,377
Thanks: 5
Salathe is on a distinguished road
Default

Just embedding Wildhoney's attachment into a post to save unnecessary downloading.

PHP Code:
<head>
    <
title>TalkPHP Dynamically Add Fields</title>
</
head>
<
body>

    <
input type="button" value="Add Necessary Fields" onclick="TalkPHP_Dynamic.addCd();">
    
    <
div id="pDynamicFormCd"></div>

    <
script type="text/javascript">
    
        var 
TalkPHP_Dynamic 
        {
            
addCd: function()
            {
                var 
pBase document.getElementById('pDynamicFormCd');
                
                var 
pCd document.createElement('input');
                var 
pYear document.createElement('input');
                var 
pRecorded document.createElement('input');
                
                
pCd.setAttribute('name''cd');
                
pCd.setAttribute('value''Album');
                
pBase.appendChild(pCd);
                
                
pYear.setAttribute('name''year');
                
pYear.setAttribute('value''year');
                
pBase.appendChild(pYear);
                
                
pRecorded.setAttribute('name''recorded');
                
pRecorded.setAttribute('value''Recorded');
                
pBase.appendChild(pRecorded);
            }
        }
    
    
</script>
    
</body> 
Salathe is offline  
Reply With Quote