All pastes #335371 Raw Edit

Unnamed

public text v1 · immutable
·published 2007-02-01 08:33 UTC
rendered paste body
I followed the tutorial here: http://www.captain.at/howto-ajax-form-post-get.php

to post data from a form to php without refreshing the page. The problem is that the variables dont get passed if i try to use divs around the form input fields to stylize things. All i am doing is divs with class names. Why does this break things and what can i do get around it?

Thanks,
Mark

######################################

The script you are using is looking for the form elements using "obj.childNodes[i]"

But when you wraped them in divs they can no longer be found using "obj.childNodes[i]" because the divs are in that section you would have to do something like:

obj.childNodes[i].childNodes[x]

But do not change them to what i just posted it won't work like that.

######################################


Nested For loops, going though the first childNodes object then going though the childNodes object of the first. So...

Code:

var nodes = obj.childNodes;
var l = nodes.length;

for (var i = 0; i < l; i++) {
    if (nodes.tagName.toLower == 'div') {
        var children =  nodes.childNodes;
        // For loop...
    }

    // check for input elements like normal...
}

General Idea don't have a lot of time at the moment.