0

I have the following jsp code below. I am having issues with Firefox sending different parameters in the get method than Interenet Explorer. Any ideas?

Here is the get url:

Internet Explorer: http://www.example.com/app/search/SkillSearch.do?dispatch=skillSearch2&textSearch=test&search=&searchField=test&searchType=

Firefox: http://www.example.com/app/search/SearchPeople.do?dispatch=&textSearch=&search=&searchField=test&searchType=

<script>
function doSearch(selection,searchInfo){
    // Get the Search Bar Form
    var searchForm = document.getElementById('searchBarForm').firstChild;

    // Get the dispatch input in the Search Bar Form
    var searchFormChildren = searchForm.childNodes;
    var dispatch;
    for (var i=0; i<searchFormChildren.length; i++) {
        if (searchFormChildren[i].name == "dispatch") {
            dispatch = searchFormChildren[i];
            break;
        }
    }

    // Variable to hold search input
    var searchField;

    // Set form variables depending on type of search selected
    if (selection.selectedIndex == "0") {
        dispatch.value = "skillSearch2";
        searchForm.action = "/app/search/SkillSearch.do";

        for (var i=0; i<searchFormChildren.length; i++) {
            if (searchFormChildren[i].name == 'textSearch') {
                searchField = searchFormChildren[i];
                break;
            }
        }
    }
    else if (selection.selectedIndex == "1") {
        dispatch.value = "searchPeople";
        searchForm.action = '/app/search/SearchPeople.do';

        for (var i=0; i<searchFormChildren.length; i++) {
            if (searchFormChildren[i].name == 'search') {
                searchField = searchFormChildren[i];
                break;
            }
        }
    }
    else if (selection.selectedIndex == "2") {
        dispatch.value="search";
        searchForm.action = '/app/search/LinkSearch.do';

        for (var i=0; i<searchFormChildren.length; i++) {
            if (searchFormChildren[i].name == 'search') {
                searchField = searchFormChildren[i];
                break;
            }
        }
    }

    searchField.value = searchInfo.value;
    searchForm.submit();
}

function checkKeyPress(selection, searchInfo) {
    if (window.event && window.event.keyCode == 13) {
        doSearch(selection, searchInfo);
    }
}
</script>

<logic:present name="SSO_TOKEN" scope="session">
    <p id="searchBarForm">
        <html:form action="/search/SearchPeople.do" method="get">
            <input type="hidden" name="dispatch" value=""/>
            <input type="hidden" name="textSearch" value="" />          <input type="hidden" name="search" value="" /> 
            <input size="15" name="searchField" value="Search" onfocus="if (this.value == 'Search') this.value = '';" onkeypress="checkKeyPress(searchType, searchField)"/>&nbsp;&nbsp;&nbsp;&nbsp;
            <select class="select" name="searchType" size="1" style="font-size: 13px;" onkeypress="checkKeyPress(searchType, searchField)">
                <option value="" selected>Subject Matter Experts</option>
                <option value="">Users</option>
            </select>&nbsp;&nbsp;&nbsp;&nbsp;
            <input class="button" type="button" value="Search" onclick="doSearch(searchType, searchField)" />
        </html:form>
    </p>
</logic:present>
0

2 Answers 2

3

Validate. Validate. Validate. A paragraph cannot contain a form, and different browsers appear to be recovering from that error in different ways.

Additionally, don't assume that the first element and the first child are the same. Some browsers will create a textNode consisting entirely of whitespace when you have: <foo> <bar></bar> </foo>.

Sign up to request clarification or add additional context in comments.

1 Comment

Technically, <input> tags are not officially allowed as direct children of <form> elements until HTML 5, either. stackoverflow.com/questions/5439078
1

David Dorward's answer is spot on. Compare IE and Firefox at http://software.hixie.ch/utilities/js/live-dom-viewer/saved/949 (which is more or less your markup, assuming you're serving up a quirks-mode document)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.