Connecting Tech Pros Worldwide Help | Site Map

Bypassing blamk fields

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 23rd, 2005, 10:43 AM
Kelley Perry
Guest
 
Posts: n/a
Default 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?



  #2  
Old July 23rd, 2005, 10:43 AM
Ron
Guest
 
Posts: n/a
Default 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;
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.