issue121, add some js-checks if objects are there
authorAndreas Unterkircher <unki@netshadow.at>
Sat, 24 May 2008 10:46:37 +0000 (12:46 +0200)
committerAndreas Unterkircher <unki@netshadow.at>
Sat, 24 May 2008 10:46:37 +0000 (12:46 +0200)
Signed-off-by: Andreas Unterkircher <unki@netshadow.at>
phpfspot.js

index be62cfb..8db1f65 100644 (file)
@@ -277,17 +277,21 @@ function startSearch()
    var objTemp = new Object();
    objTemp['action'] = 'search';
 
-   if(document.getElementsByName('searchfor_tag')[0].value != "") {
+   if(document.getElementsByName('searchfor_tag')[0] != undefined &&
+      document.getElementsByName('searchfor_tag')[0].value != "") {
       objTemp['for_tag'] = document.getElementsByName('searchfor_tag')[0].value;
    }
-   if(document.getElementsByName('searchfor_name')[0].value != "") {
+   if(document.getElementsByName('searchfor_name')[0] != undefined &&
+      document.getElementsByName('searchfor_name')[0].value != "") {
       objTemp['for_name'] = document.getElementsByName('searchfor_name')[0].value;
    }
-   if(document.getElementsByName('consider_date')[0].checked == true) {
+   if(document.getElementsByName('consider_date')[0] != undefined &&
+      document.getElementsByName('consider_date')[0].checked == true) {
       objTemp['from'] = from;
       objTemp['to'] = to;
    }
-   if(document.getElementsByName('consider_rate')[0].checked == true) {
+   if(document.getElementsByName('consider_rate')[0] != undefined &&
+      document.getElementsByName('consider_rate')[0].checked == true) {
       objTemp['rate_from'] = rate_search['from'];
       objTemp['rate_to'] = rate_search['to'];
    }
@@ -346,16 +350,19 @@ function setViewMode(mode)
  */
 function clearSearch()
 {
-   document.getElementsByName('searchfor_tag')[0].value = '';
-   document.getElementsByName('searchfor_name')[0].value = '';
+   if(document.getElementsByName('searchfor_tag')[0] != undefined)
+      document.getElementsByName('searchfor_tag')[0].value = '';
+   if(document.getElementsByName('searchfor_name')[0] != undefined)
+      document.getElementsByName('searchfor_name')[0].value = '';
 
-   if(document.getElementsByName('consider_date')[0].checked == true) {
+   if(document.getElementsByName('consider_date')[0] != undefined &&
+      document.getElementsByName('consider_date')[0].checked == true) {
       document.getElementsByName('consider_date')[0].checked = false;
       datesearch();
    }
-   if(document.getElementsByName('consider_rate')[0].checked == true) {
+   if(document.getElementsByName('consider_rate')[0] != undefined &&
+      document.getElementsByName('consider_rate')[0].checked == true) {
       document.getElementsByName('consider_rate')[0].checked = false;
-      datesearch();
    }
 
 } // clearSearch()