wffweb/src/main/java/com/webfirmframework/wffweb/tag/html/formsandinputs/Form.java
public String getIdBasedJsObject(final String functionName,
            final Collection<String> onlyForTagNames) {

        // "{" should not be changed to '{' if passing arg in constructor of
        // StringBuilder
        final StringBuilder jsObjectBuilder = new StringBuilder("{");
        final Set<String> appendedValues = new HashSet<>();

        loopThroughAllNestedChildren(child -> {

            final String tagName = child.getTagName();

            if (onlyForTagNames.contains(tagName)) {

                final AbstractAttribute idAttr = child
                        .getAttributeByName(AttributeNameConstants.ID);

                final AbstractAttribute typeAttr = child
                        .getAttributeByName(AttributeNameConstants.TYPE);

                if (idAttr != null) {
                    final String idAttrValue = idAttr.getAttributeValue();

                    if (!appendedValues.contains(idAttrValue)) {

                        final String docById = functionName + "('" + idAttrValue
                                + "')";

                        if (typeAttr != null) {

                            final String typeAttrValue = typeAttr
                                    .getAttributeValue();

                            if (Type.CHECKBOX.equals(typeAttrValue)
                                    || Type.RADIO.equals(typeAttrValue)) {

                                jsObjectBuilder.append(idAttrValue).append(':')
                                        .append(docById).append(".checked,");
                                appendedValues.add(idAttrValue);

                            } else {
                                jsObjectBuilder.append(idAttrValue).append(':')
                                        .append(docById).append(".value,");
                                appendedValues.add(idAttrValue);

                            }
                        } else {
                            jsObjectBuilder.append(idAttrValue).append(':')
                                    .append(docById).append(".value,");
                            appendedValues.add(idAttrValue);

                        }

                    }
                }

            }
            return true;
        }, false, this);

        return jsObjectBuilder.replace(jsObjectBuilder.length() - 1,
                jsObjectBuilder.length(), "}").toString();
    }
public String getIdBasedJsObject(final String functionName,
            final Collection<String> onlyForTagNames) {

        // "{" should not be changed to '{' if passing arg in constructor of
        // StringBuilder
        final StringBuilder jsObjectBuilder = new StringBuilder("{");
        final Set<String> appendedValues = new HashSet<>();

        loopThroughAllNestedChildren(child -> {

            final String tagName = child.getTagName();

            if (onlyForTagNames.contains(tagName)) {

                final AbstractAttribute idAttr = child
                        .getAttributeByName(AttributeNameConstants.ID);

                final AbstractAttribute typeAttr = child
                        .getAttributeByName(AttributeNameConstants.TYPE);

                if (idAttr != null) {
                    final String idAttrValue = idAttr.getAttributeValue();

                    if (!appendedValues.contains(idAttrValue)) {

                        final String docById = functionName + "('" + idAttrValue
                                + "')";

                        if (typeAttr != null) {

                            final String typeAttrValue = typeAttr
                                    .getAttributeValue();

                            if (Type.CHECKBOX.equals(typeAttrValue)
                                    || Type.RADIO.equals(typeAttrValue)) {

                                jsObjectBuilder.append(idAttrValue).append(':')
                                        .append(docById).append(".checked,");
                                appendedValues.add(idAttrValue);

                            } else {
                                jsObjectBuilder.append(idAttrValue).append(':')
                                        .append(docById).append(".value,");
                                appendedValues.add(idAttrValue);

                            }
                        } else {
                            jsObjectBuilder.append(idAttrValue).append(':')
                                    .append(docById).append(".value,");
                            appendedValues.add(idAttrValue);

                        }

                    }
                }

            }
            return true;
        }, false, this);

        return jsObjectBuilder.replace(jsObjectBuilder.length() - 1,
                jsObjectBuilder.length(), "}").toString();
    }
prepares and gets the js object for the given tag names under this form
tag. This js object may be used to return in onsubmit attribute.


@param functionName
the function name to get the element, eg:
document.getElementById
@param onlyForTagNames

TagNameConstants.INPUT,
TagNameConstants.TEXTAREA and
TagNameConstants.SELECT Pass object of
{@code List}, {@code HashSet} based on the
number of elements in it.


@return the js object string for the given tag names. The returned js
string will be as {name1:document.getElementById('name1').value}
where name1 is the value of id attribute of the field.
@since 3.0.1
@author WFF