Jump to content

RussellParker

Members
  • Content Count

    10
  • Joined

  • Last visited

  1. Well.... As I suspected I was being a dolt. I had an HTML box above the Search Fields giving instructions. It was Value1 and "getElementById()" was not working against it and returning Null. Executing the ".value" method against a Null object was causing the Script to short circuit. Instead of using "Value1_1" and "Value2_1" I changed it to "Value2_1" and "Value3_1" and all was well.
  2. Well.... As I suspected I was being a dolt. I had an HTML box above the Search Fields giving instructions. It was Value1 and "getElementById()" was not working against it and returing Null. Executing the ".value" method against a Null object was causing the Script to short circuit. Instead of using "Value1_1" and "Value2_1" I changed it to "Value2_1" and "Value3_1" and your script works perfectly.
  3. Done. URL sent to you in a PM. Thanks! I did some more testing and I think the heart of my problem is "Value1_1". It does not seem to be accepting that as a valid ElementId since:. var element = document.getElementById("Value1_1"); results in "element" being "null"
  4. Hi Elena, To the best of my knowledge MSSQL does not have a native Median() function that I am aware of. You seem to basically be doing what you need to. Sorting based on the field in question and then going to the middle row and taking that value. If you are still having a problem with this I can mess around with it.
  5. I initially posted a question over in Data Pages and got what looks like a answer which should work. However I am having trouble getting the suggested Java Script to work. From that other Thread... I was looking at this more and wondering if I needed to change the "Value1_1" and "Value2_1" strings to be specific to the Name or ID of the Controls on my Search Page, but I did not see anything which looked like what this might be. Then I found this in the "JavaScript Tips: Caspio Form Elements" help article... Search Forms Text Field/Text Area/Dropdown/Checkbox/Listbox/Hidden: - ValueX_Y - X is the form element order, which starts at 1 and increments based on the order of the element in the form. - Y is the criteria. It starts at 1 and increments based on criteria order. It is always 1 if the field has no extra criteria. ... which suggests to me I should not call my Search Fields "Controls"... I should call them "Elements". Further they are not referenced by specific name, but rather by their position in the Form. So if I have two Search Fields (both which are Text Fields... "Registration" and "Name"... in that order) a call to: document.getElementById("Value1_1").value; ...should theoretically get me the data entered for "Registration". (A separate question is how to tell what the available "criteria" are for an Element, but I am working on the assumption that critera 1 in this case is the data entered by the User). I have yet to get this to work though. As far as I can tell the moment I add the "document.getElementById(..." call to the code it appears to short-circuit. If I have the following... function check() { window.alert("1"); window.alert("2"); } document.getElementById("searchID").onclick=check; ... then when I click "Search" I get a pop-up box with "1", then another with "2", and it goes to the Results Page. If I have this instead... function check() { window.alert("1"); window.alert(document.getElementById('Value1_1').value); window.alert("2"); window.alert(document.getElementById('Value2_1').value); } document.getElementById("searchID").onclick=check; ... then I get a pop-box with "1" and then it goes directly to to the Results Page. It hits the "document..." code and goes *POOF* Guessing this is bone-head simple and I am just a little to ignorant of things to understand what I am doing wrong. Help! Russ
  6. When using the "Contains" comparison type the basic behavior is useful in many cases, but it can also be problematic. I am wondering if anyone knows of a way to prevent it from parsing what is entered in the Search Field. Here is the issue in more detail. Contains | Does Not Contain Keyword is searched within a text field or a file name field. If multiple keywords are entered in the search field, AND operator is assumed between them. User can also provide a desired operator by entering it in ALL CAPS (reference: http://howto.caspio.com/datapages/reports/search-and-filter-comparison-types/) The problem is in how the data entered is parsed. Similarly to how a search would work in something like Google, the system presumes spaces are delimiters unless they are enclosed in quotes. So if your search for: A B it will match against A B C D and D C B A since it gets transformed logically into Contains("A") AND Contains("B") Now if you search for: "A B" it will match against A B C D but not D C B A since quotes force what is between them to be treated as a single literal. Generally this behavior is likely just fine and not even noticed, but in certain cases it can matter quite a lot. Example 1: You want to search for animals with "ABC Farms" in their name. Unless your Users know to add the Quotes they will get all animals which have both ABC and Farms anywhere in their name, rather than ABC Farms. This case is not all that big a problem since it can be solved with a bit of User Education. It would be nice however to be able to disable the functionality and make it act more like it would as just a simple Database Query, Example 2: This one is a bigger problem since it comes up when a Nefarious User knows too much. What if I only wanted you to be able to look up a case you knew something about... for example the middle 8 numbers of its Case Number. (please grant for the moment there might be some reason to do this... lol). Say a Case Number looks like 2-6 Alpha Characters... 8 Numerals.. and 0-4 Alpha Characters. All the User knows is the middle portion with the 8 Numerals and you only want them to be able to look up cases which contain that specific string. No problem... they enter 12345678 and it finds anything containing that. Enter our Nefarious User who enters 1 OR 2 OR 3 OR 4 OR 5 OR 6 OR 7 OR 8 OR 9 and gets a listing of every case in the system. Yikes! Parsing what is entered into the Search Field in Keywords in nice Functionality to have available, but we need a way to say NO to it. It would also be nice to be able to choose if the assumed operator will be OR instead of AND. Thanks in Advance.. Russell
  7. From the "JS Guide: Caspio Form Elements" there is this: Search Forms Text Field/Text Area/Dropdown/Checkbox/Listbox/Hidden: - ValueX_Y - X is the form element order, which starts at 1 and increments based on the order of the element in the form. - Y is the criteria. It starts at 1 and increments based on the criteria order. It is always 1 if the field has no extra criteria. My question is how does one know what the "Criteria Order" is for the different Element Types? Is this documented somewhere? Thanks, Russ
  8. I was looking at this more and wondering if I needed to change the "Value1_1" and "Value2_1" strings to be specific to the Name or ID of the Controls on my Search Page, but I did not see anything which looked like what thus might be. Then I found this in the "JavaScript Tips: Caspio Form Elements" help article. Search Forms Text Field/Text Area/Dropdown/Checkbox/Listbox/Hidden: - ValueX_Y - X is the form element order, which starts at 1 and increments based on the order of the element in the form. - Y is the criteria. It starts at 1 and increments based on criteria order. It is always 1 if the field has no extra criteria. So this suggests to me I should not call my Search Fields "Controls"... I should call them "Elements". Further they are not referenced by specific name, but rather by their position in the Form. So I have two Search Fields, both which are Text Fields... "Registration" and "Name". In this order a call to: document.getElementById("Value1_1").value; ...should theoretically get me the data entered for "Registration" although I do not se how to tell what the available "criteria" are. I have yet to get this to work though. As far as I can tell though the moment I add the "document.getElementById(..." call to the code it appears to short-circuit. If I have the following... function check() { window.alert("1"); window.alert("2"); } document.getElementById("searchID").onclick=check; Then when I click "Search" I get a pop-up box with "1", then another with "2", and it goes to the Results Page. If I have this instead... function check() { window.alert("1"); window.alert(document.getElementById('Value1_1').value); window.alert("2"); window.alert(document.getElementById('Value2_1').value); } document.getElementById("searchID").onclick=check; Then I get a pop-box with "1" and then it goes to the Results Page. It hits the "document..." code and goes *POOF* Guessing this is just bone-head simple and I am just a little to ignorant of things to understand what I am doing wrong. Russ
  9. Thank you! Unfortunately I tried you code, but I could not get it to work. With a little pruning I was able to get it to reject everything though, so at least I know I am putting the code in the proper place. ============================================ <SCRIPT LANGUAGE="JavaScript"> function check() { var first = ""; var second = ""; if (( first.length === 0) & ( second.length === 0)) { window.alert("Please enter a value in a field"); return false; } } document.getElementById("searchID").onclick=check; </SCRIPT> ============================================ It does not seem to like how you were getting the Values of the Search Fields since if I use: var first= document.getElementById("Value1_1").value; var second = document.getElementById("Value2_1").value; It just sails on past without a problem. Or an error interestingly enough. Was I supposed to leave those as written did I need to replace them with something specific to my Search Page? Any thoughts?
  10. I have built a "Search and Report" data page with several fields available for search added under "Configure Search Fields". Each of the fields has a minimum number of characters and is a "Contains" match. This works perfectly if data is entered in any of them. The problem is that if no data is entered in ANY of the Search Fields it brings back the entire data set. I do not want to make any specific field required, I just one at least one of the Search Fields to have had a value entered to search for. Said another way I want to disallow the "All Blanks" case. Any thoughts? Thanks is Advance... Russ
×
×
  • Create New...