ICE + Javascript validation script != success



Hello experts,

I have been struggling for days to solve this problem and every
suggestion I find via Google does not work for me. There is probably a
solution out there that will do what I want, but I probably have not
properly implemented the solutions I find.

I am trying to make a page to allow personnel the ability to search our
backend DB (which is Ingres 2.0) through a web interface using ICE
2.0. I have lots of pages setup that query correctly and work really
well. The one I am struggling with is searching our parts database
because I want to allow wildcard searches. Since the Ingres wildcard is
a % sign I can input 011% and it will find any item number that starts
with 011. I can use %011% and it will find any part with 011 in the
string. I only care about three fields item_no, description_1, and
description_2 for searching.

I have set up a simple form that queries properly using only hidden
variables and GET and no javascript, but the wildcards have to be
explicitly entered in the form. I want to use javascript to validate
the form and add the wildcards for the user.

So, here is the incredibly ugly code I hacked together that almost
achieves what I want. The problem is using either GET or POST for the
action, the query the DB receives does not have "item_no like '011%' "
instead it is "item_no like '011' " so it returns ONLY the item with
item_no EXACTLY 011. Not helpful. If I use an alert to display the
send_string before the submit, it has wildcards in the string as I
expect but for some reason when I look in the DB logs and the apache
logs the query has no % and the GET statement passed to apache has no %
signs. What can I do to validate the form and get the strings passed to
the query with the % wildcards intact?

I want the user to only have to fill in what he cares about and then I
can validate and correctly compose the SQL query from there. The most
common example is to fill in the item_no with a string. I then make the
two description fields a single % so the query returns any items that
match the item_no without caring about the description fields. That is
why the code checks if all fields in one group are empty, it makes the
contains parameter for this field a single %.

Anyone who can steer me the correct way will be much appreciated.

Everything I have read indicates ICE 2.5 or 3.0 has IFs and more power
like that so I bet this would be pretty easy then, but our backend it
still 2.0 because this is what our ERP runs on. There is basically no
issue with security because it is on an intranet and only about 5
people in the company will ever use it.


<SCRIPT LANGUAGE="Javascript">
<!--
function checkme(parts) {
var start_string=document.forms[0].start_item_no.value;
var length_start_string=start_string.length;
var contains_string=document.forms[0].contains_item_no.value;
var length_contains_string=contains_string.length;
var end_string=document.forms[0].end_item_no.value;
var length_end_string=end_string.length;
if (length_start_string != 0) {start_string=start_string+"%"};
if (length_contains_string != 0)
{contains_string="%"+contains_string+"%"};
if (length_end_string != 0) {end_string="%"+end_string};
if (length_start_string== 0 && length_contains_string==0 &&
length_end_string==0) {contains_string="%"};
var
send_string="start_item_no="+start_string+"&contains_item_no="+contains_string+"&end_item_no="+end_string;
var start_desc1=document.forms[0].start_description_1.value;
var length_start_desc1=start_desc1.length;
var contains_desc1=document.forms[0].contains_description_1.value;
var length_contains_desc1=contains_desc1.length;
var end_desc1=document.forms[0].end_description_1.value;
var length_end_desc1=end_desc1.length;
if (length_start_desc1 != 0) {start_desc1=start_desc1+"%"};
if (length_contains_desc1 != 0)
{contains_desc1="%"+contains_desc1+"%"};
if (length_end_desc1 != 0) {end_desc1="%"+end_desc1};
if (length_start_desc1==0 && length_contains_desc1==0 &&
length_end_desc1==0) {contains_desc1="%"};
send_string=send_string+"&start_description_1="+start_desc1+"&contains_description_1="+contains_desc1+"&end_description_1="+end_desc1;
var start_desc2=document.forms[0].start_description_2.value;
var length_start_desc2=start_desc2.length;
var contains_desc2=document.forms[0].contains_description_2.value;
var length_contains_desc2=contains_desc2.length;
var end_desc2=document.forms[0].end_description_2.value;
var length_end_desc2=end_desc2.length;
if (length_start_desc2 != 0) {start_desc2=start_desc2+"%"};
if (length_contains_desc2 != 0)
{contains_desc2="%"+contains_desc2+"%"};
if (length_end_desc2 != 0) {end_desc2="%"+end_desc2};
if (length_start_desc2==0 && length_contains_desc2==0 &&
length_end_desc2==0) {contains_desc2="%"};
send_string=send_string+"&start_description_2="+start_desc2+"&contains_description_2="+contains_desc2+"&end_description_2="+end_desc2;
document.parts.action="http://192.168.254.238/cgi-bin/ice/macro_partsearch.html?"send_string;
document.parts.submit();
} //submit function
-->
</SCRIPT>
<FORM NAME="parts" METHOD="GET" onSubmit="javascript:checkme(this);">


<P>
Enter a string that the item number begins with
<INPUT TYPE=text NAME="start_item_no" VALUE=""><br>
Enter a string that the item number contains
<INPUT TYPE=text NAME="contains_item_no" VALUE=""><br>
Enter a string that the item number ends with
<INPUT TYPE=text NAME="end_item_no" VALUE="">
<br><p>
Enter a string that description 1 begins with
<INPUT TYPE=text NAME="start_description_1" VALUE=""><br>
Enter a string that description 1 contains
<INPUT TYPE=text NAME="contains_description_1" VALUE=""><br>
Enter a string that description 1 ends with
<INPUT TYPE=text NAME="end_description_1" VALUE="">
<br><p>
Enter a string that description 2 begins with
<INPUT TYPE=text NAME="start_description_2" VALUE=""><br>
Enter a string that description 2 contains
<INPUT TYPE=text NAME="contains_description_2" VALUE=""><br>
Enter a string that description 2 ends with
<INPUT TYPE=text NAME="end_description_2" VALUE="">
<br><p>
<INPUT TYPE="submit" VALUE="Find">

<CENTER>
</CENTER>
</FORM>

.



Relevant Pages

  • GET and POST dropping wildcard characters in DB query
    ... I have been struggling for days to solve this problem and every ... I have lots of pages setup that query correctly and work really ... variables and GET and no JS, but the wildcards have to be explicitly ... send_string before the submit, it has wildcards in the string as I ...
    (comp.lang.javascript)
  • Re: WildCard Key
    ... But I have a new need to support filenames based on wildcards. ... I'd use a prefix tree aka trie both ... An empty string matches a terminal vertex ... stars that contains at least one star, ...
    (microsoft.public.vc.stl)
  • Re: wildcard woes
    ... Thinking the wildcards would work I try this ... In brief, Filemaker does a word search from the beginning of a word, for any string you put into a field. ... So for your desired searching a single request with "red yellow" in the field will work. ... These might be of assistance if you look them up in the help file and see how they are used in FM. ...
    (comp.databases.filemaker)
  • Re: Help configuring Symantec NIS ad blocking - tech support is worthless
    ... > Wildcards do not work when adding strings to the NIS ad blocking list. ... finally issued a specific response. ... will match for the length of the supplied rule string. ...
    (comp.security.firewalls)
  • Re: Find and Replace
    ... wildcards but will just have to sit down and get to grips with them through ... Greg Maxey/Word MVP ... MarkN wrote: ... Again <s anchors the start of a find string to a word starting with ...
    (microsoft.public.word.docmanagement)