Bypassing blamk fields

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Kelley Perry

    #1

    Bypassing blamk fields

    I have one form, many text input types which allow users to to do a search
    of my image database. It is possible, with this form to leave certain text
    fields blank.
    Is there a way to use javascipt to bypass blank fields in a search? I dont
    want to take up processor time or see the blank name/value pairs in the
    query string. Anyone know what i mean?


  • Ron

    #2
    Re: Bypassing blamk fields

    Kelley Perry wrote:
    [color=blue]
    >I have one form, many text input types which allow users to to do a search
    >of my image database. It is possible, with this form to leave certain text
    >fields blank.
    >Is there a way to use javascipt to bypass blank fields in a search? I dont
    >want to take up processor time or see the blank name/value pairs in the
    >query string. Anyone know what i mean?
    >
    >
    >
    >[/color]
    Just use a conditional. If the javascript is generating an URL query
    string by looping through inputs, it may look something like this:

    var myURL = "http://www.mywebsite.c om/myformhandler.p hp?";
    var myInputs =
    document.getEle mentById("myFor m").getElements ByTagName("inpu t");
    for(i=0;i<myInp uts.length;i++) {
    myURL += (myInputs[i].value=="") ? "" : myInputs[i].name + "=" +
    myInputs[i].value + "&";
    }
    myURL = encodeURI(myURL );
    window.location .href = myURL;

    Comment

    Working...