July 20, 200322 yr I saw Garrys solution to searching multiple fields but can't seem to get it working. I have began fiddeling on my own solution (a bit smilar to Garrys perhaps) but have come to a dead end. It basically has to do with handling of characters in javascript. I thought of creating two fields on my search page: one main field and one field which connects to a related database. The related field is to be updated automatically with the contents entered in the main field. When a user submits the search the two fields are searched. Here is the javascript I found on the web: <script language="JavaScript"><!-- function copyData(from,to) { to.value = from.value; } //--></script> The form is basic so far untill I get the script working with the characters. I thought this would work: <form name="-find"> <input type="text" name="webFind" onChange="copyData(this,document.-find.guestbook::comment)" onKeyUp="copyData(this,document.-find.guestbook::comment)"> <input type="text" name="guestbook::comment" onChange="copyData(this,document.-find.webFind)" onKeyUp="copyData(this,document.-find.webFind)"> </form> The script doesn't seem to like a form called -find ( which it has to be called right?) or a text field with "::". I saw Garrys solution to the "::" problem, but it doesn't seem to work.... Help much appreciated. /Kevin
July 20, 200322 yr Author Thank you Olivier, but couldn't get it to work. Would you mind posting the whole form code after your change? Did you get it to work? Thanks, Kevin
July 21, 200322 yr Kevon, Note that the "solution" I published for Rivet was for mixed "AND/OR" logic. It also used one field (date) as the the "AND" field. And, it depended on a Calculated field to complement this mixed logic. In relation to the Javascript: - You do not need to pass document objects to a Function. - I'm not sure why you are swapping field values. - There is no need to name a Form "-find". To search on the two fields { webFind and guestbook::Comment } I would use a Form like this: <form action="FMPro" method="POST"> <input type="hidden" name="-db" value="mydatabase.fp5"> <input type="hidden" name="-lay" value="myLayout"> <input type="hidden" name="-format" value="myretsults.html"> <input type="text" name="webFind" value=""> <input type="text" name="guestbook::Comment" value=""> <input type="submit" name="-find" value="Find Records"> </form> Hope this helps. Garry
July 21, 200322 yr Author Thanks Garry. The "-find" problem seems to be ok now... I will try to be a bit clearer about my other problem. What I want to do: Search two fields in a database with only using one html text field. I found your thread (http://www.fmforums.com/threads/showflat.php?Cat=&Board=UBB22&Number=58150&Forum=UBB22&Words=web%20search&Match=And&Searchpage=1&Limit=25&Old=allposts&Main=57827&Search=true#Post58150) , but couldn't get it to work, so I tried to construct an one from scratch. Solution: Instead of having one text field on a html page I can settle with two as long as they reflect the same contents (I can always hide the second field). So entering xxx data in html text field one renders xxx in html field two automatically. I found this javascript which allows for this. My code is simplified below, but works. The problem occurs when I want to us a realtionship (guestbook::comments) to search another database. I have problems incorporating "guestbook::comments" into this piece of javascript: copyData(this,window.document.form.HEREGOESFIELDNAME) Do you know how to fix this (using :: in a javascript)? <html> <head> <script language="JavaScript"><!-- function copyData(from,to) { to.value = from.value; } //--></script> </head> <body> <form action="FMPro" name="form"> <input type="hidden" name="-op" value="cn"> <input type="text" name="webFind" onChange="copyData(this,window.document.form.Portalfieldkommentar)" onKeyUp="copyData(this,window.document.form.Portalfieldkommentar)"> <INPUT TYPE="hidden" NAME="-lop" VALUE="or"> <input type="hidden" name="-op" value="cn"> <input type="text" name="Portalfieldkommentar" onChange="copyData(this,window.document.form.webFind)" onKeyUp="copyData(this,window.document.form.webFind)"> <input type="hidden" name="-db" value="pharmafakta.fp5"> <input type="hidden" name="-layout" value="1"> <input type="hidden" name="-format" value="results.htm"> <input type="hidden" name="name" value="-find"> <input type="submit" name="-find" value="Search"> </form> </body> </html>
July 21, 200322 yr Author Well, it seems I got it working with the following: window.document.form.elements['guestbook::Kommentar'] Think it is the same as Garrys solution in the discussion mentioned above. Strange it didn't work before... Here is a great resource for javascript: http://developer.irt.org/script/script.htm Thanks all.
July 21, 200322 yr Author Garry, just thought I would let you know I got your javascript working after some work... Thanks, Kevin
July 21, 200322 yr Good to see that it is working Here is an alternative method for using the Form values in the Javascript: <head> <script language="JavaScript"><!-- function copyData(direction) { if (direction == "one") { document.form.Portalfieldkommentar.value = document.form.webFind.value; } else { document.form.webFind.value = document.form.Portalfieldkommentar.value; }; } //--></script> </head> <body> <form action="FMPro" name="form"> <input type="hidden" name="-op" value="cn"> <input type="text" name="webFind" onChange="copyData('one')" onKeyUp="copyData('one')"> <INPUT TYPE="hidden" NAME="-lop" VALUE="or"> <input type="hidden" name="-op" value="cn"> <input type="text" name="Portalfieldkommentar" onChange="copyData('two')" onKeyUp="copyData('two')"> All the best. Garry
July 21, 200322 yr HI! > Poor Garry must have JS nighmares by now ...I know I alone have given him enough " nighmare materil" Public thanx to Garry for JS Support!
July 22, 200322 yr Some people play Solitaire for "Thinking Time". I attempt FM/Javascript challenges (Gets my brain working in the mornings!) All the best. Garry
Create an account or sign in to comment