add a search text field to another filter function

Discussion in 'Javascript' started by css-discuss.org, Jan 12, 2012.

  1. I have added the 2 asterisks lines for the search field for
    orderNumber ****:
    This page is using YUI so its complicated to explain but the function
    I need to change should be simple js.
    --------------HTML-----------------------
    <div id="filtersDiv">
    **Order Number: <input type="text" id="filterOrderNumber"
    name="filterOrderNumber" size="10" value="" />
    ** <input id="filterSearch"
    type="submit" />
    <ui>
    <li id="process">ProcessCode: </li>
    <li id="system">SystemCode: </li>
    <li id="plant">Plant: </li>
    </ul>
    <ul>
    <li>Start Date: <input type="text" id="startDate" name="startDate" /
    ><input type="hidden" id="xmlStartDate" name="xmlStartDate" /></li>

    <li>End Date: <input type="text" id="endDate" name="endDate" /><input
    type="hidden" id="xmlEndDate" name="xmlEndDate" /></li>
    <li>empNo: <input type="text" id="empNo" name="emp" size="4" value="" /
    ></li>

    <li><input id="filterSubmit" type="submit"></li>
    </ul>
    </div>
    -----------------------
    I added the 2nd filterClickHandler2 event to listen for the
    searchOrderNumber field.

    var filterClickHandler = function(){
    YAHOO.log("filter clicked");
    var xmlStartDate = YAHOO.util.Dom.get("xmlStartDate").value;
    var xmlEndDate = YAHOO.util.Dom.get("xmlEndDate").value;
    var plant = YAHOO.util.Dom.get("userPlant").value;
    var submitType='filterSubmit';
    loadSecondaryFilters(xmlStartDate, xmlEndDate, plant);
    var configURL = getConfigURL(xmlStartDate, xmlEndDate,submitType);
    loadDataTable(configURL);
    };
    YAHOO.util.Event.addListener("filterSubmit", "click",
    filterClickHandler);


    var filterClickHandler2 = function(){
    YAHOO.log("orderNumber filter clicked"); //
    var orderNumber = YAHOO.util.Dom.get("orderNumber").value;
    var submitType='filterSearch';
    var configURL = getConfigURL(submitType);
    loadDataTable(configURL);
    };
    YAHOO.util.Event.addListener("filterSearch", "click",
    filterClickHandler2);


    I added the submitType var to the clickhandler functions.
    Now I need to alter the function getConfigURL() to accomodate for
    both filters.

    function getConfigURL(xmlStartDate, xmlEndDate,submitType) { //
    1_11_2012 jr added submitType
    var plant = YAHOO.util.Dom.get("userPlant").value;
    if ( submitType='filterSubmit'){

    var configURL = "/XMII/Illuminator?Transaction=" +
    CN.config.GLOBAL_DIR + "/Message%20Queue/
    GetMessageQueue&Server=XacuteConnector&Mode=Query&RowCount=99999&OutputParameter=outputXML&Content-
    Type=text/xml&key=message";
    configURL += "&ST=" + xmlStartDate;
    configURL += "&ET=" + xmlEndDate;
    configURL += "&plant=" + plant;
    if(hasValue("empNo")) {
    configURL += "&empNo=" + YAHOO.util.Dom.get("empNo").value;
    }
    if(hasValue("processDD")) {
    configURL += "&processcd=" + YAHOO.util.Dom.get("processDD").value;
    }
    if(hasValue("systemDD")) {
    configURL += "&systemcd=" + YAHOO.util.Dom.get("systemDD").value;
    }
    if(hasValue("functionDD")) {
    configURL += "&functioncd=" +
    YAHOO.util.Dom.get("functionDD").value;
    }
    if(hasValue("pageDD")) {
    configURL += "&page=" + YAHOO.util.Dom.get("pageDD").value;
    }
    if(hasValue("moduleDD")) {
    configURL += "&module=" + YAHOO.util.Dom.get("moduleDD").value;
    }
    if(hasValue("statusDD")) {
    configURL += "&status=" + YAHOO.util.Dom.get("statusDD").value;
    }
    return configURL;
    } } else{
    //key is changed to orderNumber
    var configURL = "/XMII/Illuminator?Transaction=" +
    CN.config.GLOBAL_DIR + "/Message%20Queue/
    GetMessageQueue&Server=XacuteConnector&Mode=Query&RowCount=99999&OutputParameter=outputXML&Content-
    Type=text/xml&key=orderNumber";
    ?????
    return configURL}

    Is this right?
    Tnx,
    Jan
     
    css-discuss.org, Jan 12, 2012
    #1
    1. Advertising

  2. On Jan 11, 7:06 pm, "css-discuss.org" <>
    Okay, I added the 2nd event listener function, first is for
    filterSubmit and 2nd is for filterSearch.
    Two separate filters. I modified the config function to incorporate
    both events but there is a syntax error or a data error.
    Can you please advise? Thanks.
    var filterClickHandler = function(){
    YAHOO.log("filter clicked");
    var xmlStartDate = YAHOO.util.Dom.get("xmlStartDate").value;
    var xmlEndDate = YAHOO.util.Dom.get("xmlEndDate").value;
    var plant = YAHOO.util.Dom.get("userPlant").value;
    loadSecondaryFilters(xmlStartDate, xmlEndDate, plant);
    var configURL = getConfigURL(xmlStartDate, xmlEndDate);
    loadDataTable(configURL);
    };
    YAHOO.util.Event.addListener("filterSubmit", "click",
    filterClickHandler);


    var filterClickHandler2 = function(){ //1_11_2012 jr added function
    // YAHOO.log("orderNumber filter clicked");
    var orderNumber = YAHOO.util.Dom.get("orderNumber").value;
    var submitType=1;
    var configURL = getConfigURL(submitType);
    loadDataTable(configURL);
    };
    YAHOO.util.Event.addListener("filterSearch", "click",
    filterClickHandler2);

    function getConfigURL(submitType,xmlStartDate, xmlEndDate) {
    var plant = YAHOO.util.Dom.get("userPlant").value;
    if(submitType===undefined) { //clickHandler
    var configURL = "/XMII/Illuminator?Transaction=" +
    RN.config.GLOBAL_DIR + "/Message%20Queue/
    GetMessageQueue&Server=XacuteConnector&Mode=Query&RowCount=99999&OutputParameter=outputXML&Content-
    Type=text/xml&key=message";
    configURL += "&ST=" + xmlStartDate;
    configURL += "&ET=" + xmlEndDate;
    configURL += "&plant=" + plant;
    }else if(xmlStartDate===undefined &&
    xmlEndDate===undefined) { //clickHandler2
    var configURL = "/XMII/Illuminator?Transaction=" +
    rn.config.GLOBAL_DIR + "/Message%20Queue/
    GetMessageQueue&Server=XacuteConnector&Mode=Query&RowCount=99999&OutputParameter=outputXML&Content-
    Type=text/xml&key=orderNumber";
    configURL += "&plant=" + plant;
    }
    if(hasValue("orderNumber")){
    configURL +="&orderNumber="
    +YAHOO.util.Dom.get("orderNumber").value;
    }
    if(hasValue("empNo")) {
    configURL += "&empNo=" +YAHOO.util.Dom.get("empNo").value;
    }
    if(hasValue("processDD")) {
    configURL += "&processcd=" + YAHOO.util.Dom.get("processDD").value;
    }
    if(hasValue("systemDD")) {
    configURL += "&systemcd=" + YAHOO.util.Dom.get("systemDD").value;
    }
    if(hasValue("functionDD")) {
    configURL += "&functioncd=" +
    YAHOO.util.Dom.get("functionDD").value;
    }
    if(hasValue("pageDD")) {
    configURL += "&page=" + YAHOO.util.Dom.get("pageDD").value;
    }
    if(hasValue("moduleDD")) {
    configURL += "&module=" + YAHOO.util.Dom.get("moduleDD").value;
    }
    if(hasValue("statusDD")) {
    configURL += "&status=" + YAHOO.util.Dom.get("statusDD").value;
    }
    return configURL;
    }
     
    css-discuss.org, Jan 12, 2012
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page