Pulling form variables without knowing their names

Discussion in 'JavaScript' started by lyleyboy, Aug 15, 2007.

  1. #1
    Hi,

    I know this is possible in PHP but is there a way to pull the variables submitted from a form without knowing their names.
    I have a site that the users can change the forms and I need to process them.
     
    lyleyboy, Aug 15, 2007 IP
  2. Wildhoney

    Wildhoney Active Member

    Messages:
    192
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    58
    #2
    
    
    pContainer = document.getElementById('theFormContainer');
    
    if(!pContainer.hasChildNodes())
    {
    	// No child nodes
    	return false;
    }
    
    for(iIndex = 0; iIndex < pContainer.childNodes.length; iIndex++)
    {
    	// Loop through all the form's child nodes and get their node name
    	alert('This form element is "' + pContainer[iIndex].nodeName + '" with a value of "' + pContainer[iIndex].getAttribute('value') + '"');
    }
    
    
    Code (markup):
     
    Wildhoney, Aug 15, 2007 IP