| 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.com/myformhandler.php?";
var myInputs =
document.getElementById("myForm").getElementsByTag Name("input");
for(i=0;i<myInputs.length;i++) {
myURL += (myInputs[i].value=="") ? "" : myInputs[i].name + "=" +
myInputs[i].value + "&";
}
myURL = encodeURI(myURL);
window.location.href = myURL; |