By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,700 Members | 1,364 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,700 IT Pros & Developers. It's quick & easy.

Bypassing blamk fields

P: n/a
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?
Jul 23 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Ron
Kelley Perry wrote:
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?

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;
Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.