hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Eric Chow" <ec...@macaucabletv.com>
Subject Array of values ???
Date Mon, 07 Jul 2003 09:47:07 GMT
Hello,

The following is a HTML form with a set of same "name". How can use
HttpClient to post them ??


Best regards,
Eric


=============================

<script language="JavaScript">
  C_ITEM_NO = 5;
  C_BOOKING_HOUR_LIMIT = 3;
  function check_input() {
    i = 0;
    fillCnt = 0;
    loopCnt = C_ITEM_NO - 1;
    isPrevItemEmptyFlag = false;
    isItemValidFlag = false;
    while (i <= loopCnt) {
      isItemEmptyFlag = check_item_empty(i);
      if (isItemEmptyFlag == false) {
        if (isPrevItemEmptyFlag == true) {
          alert("Please fill in your booking items in sequential order.");
          document.bform.wv_booking_date[i-1].focus();
          return false;
        }
        isItemValidFlag = check_item(i);
        if (isItemValidFlag == false) {
          return false;
        }
      isItemDuplicated = check_item_duplication(i);
      if (isItemDuplicated == true) {
        return false;
      }

        isBookingHourOverLimit = check_item_hour_over_limit(i);
        if (isBookingHourOverLimit == true) {
        return false;
        }

        fillCnt++;
      }
      if (document.bform.chk_booking_light[i].checked) {
        document.bform.wv_booking_light[i].value = "Y";
      } else {
        document.bform.wv_booking_light[i].value = "N";
      }
      if (document.bform.chk_booking_air[i].checked) {
        document.bform.wv_booking_air[i].value = "Y";
      } else {
        document.bform.wv_booking_air[i].value = "N";
      }
      isPrevItemEmptyFlag = (isItemEmptyFlag == true)?true:false;
      i++;
    }
//    alert("fillCnt: " + fillCnt);
    if (parseInt(fillCnt) == 0) {
   alert("Please fill in at least one activity.");
      document.bform.wv_booking_date[0].focus();
      return false;
    }
    return true;
  }

  function FromTimeChange(i)
  {
    document.bform.wv_booking_time_to[i].options.selectedIndex =
    document.bform.wv_booking_time_from[i].options.selectedIndex
    return true;
  }

  function check_facility_existence (i) {
  if (document.bform.wv_booking_place[i].options.selectedIndex == 0) {
    document.bform.chk_booking_light[i].disabled=false;
    document.bform.chk_booking_air[i].disabled=false;
  }
  if (trim(document.bform.wv_booking_place[i].value) == 'PAV') {
    document.bform.chk_booking_light[i].disabled=true;
    document.bform.chk_booking_light[i].checked=false;
    document.bform.chk_booking_air[i].disabled=false;
}
  if (trim(document.bform.wv_booking_place[i].value) == 'SQ1') {
    document.bform.chk_booking_light[i].disabled=true;
    document.bform.chk_booking_light[i].checked=false;
    document.bform.chk_booking_air[i].disabled=false;
}
  if (trim(document.bform.wv_booking_place[i].value) == 'SQ2') {
    document.bform.chk_booking_light[i].disabled=true;
    document.bform.chk_booking_light[i].checked=false;
    document.bform.chk_booking_air[i].disabled=false;
}
  if (trim(document.bform.wv_booking_place[i].value) == 'T1') {
    document.bform.chk_booking_light[i].disabled=false;
    document.bform.chk_booking_air[i].disabled=true;
    document.bform.chk_booking_air[i].checked=false;
}
  if (trim(document.bform.wv_booking_place[i].value) == 'T2') {
    document.bform.chk_booking_light[i].disabled=false;
    document.bform.chk_booking_air[i].disabled=true;
    document.bform.chk_booking_air[i].checked=false;
}
  if (trim(document.bform.wv_booking_place[i].value) == 'ZDR') {
    document.bform.chk_booking_light[i].disabled=true;
    document.bform.chk_booking_light[i].checked=false;
    document.bform.chk_booking_air[i].disabled=false;
}
  if (trim(document.bform.wv_booking_place[i].value) == 'ZS1') {
    document.bform.chk_booking_light[i].disabled=true;
    document.bform.chk_booking_light[i].checked=false;
    document.bform.chk_booking_air[i].disabled=true;
    document.bform.chk_booking_air[i].checked=false;
}
  if (trim(document.bform.wv_booking_place[i].value) == 'ZS2') {
    document.bform.chk_booking_light[i].disabled=true;
    document.bform.chk_booking_light[i].checked=false;
    document.bform.chk_booking_air[i].disabled=true;
    document.bform.chk_booking_air[i].checked=false;
}
}


  function check_item(i) {
      if ( document.bform.wv_booking_date[i].options.selectedIndex == 0)
      {
        alert("The booking date is invalid");
        document.bform.wv_booking_date[i].focus();  return false;
      }
      if ( document.bform.wv_booking_place[i].options.selectedIndex == 0)
      {
        alert("The booking place is empty");
        document.bform.wv_booking_place[i].focus();  return false;
      }
      v_facilities = trim(document.bform.wv_booking_facilities[i].value);
      if (trim(document.bform.wv_booking_place[i].value) == 'PAV') {
        if (v_facilities.length == 0) {
          alert("Please specify the facilities for using the complex
Pavilion, e.g. soccer, " +
                "basketball, volleyball, badminton, table tennis or
handball,etc");
          document.bform.wv_booking_facilities[i].focus(); return false;
        }
      }
      if ( document.bform.wv_booking_time_from[i].options.selectedIndex ==
0)
      {
        alert("The booking time (FROM) is empty");
        document.bform.wv_booking_time_from[i].focus(); return false;
      }
      if ( document.bform.wv_booking_time_to[i].options.selectedIndex == 0)
      {
        alert("The booking time (TO) is empty");
        document.bform.wv_booking_time_to[i].focus(); return false;
      }
      if ( parseInt(document.bform.wv_booking_time_from[i].options.value)
             >=
           parseInt(document.bform.wv_booking_time_to[i].options.value) )
      {
        alert("Booking time (TO) should be greater than booking time
(FROM)");
        document.bform.wv_booking_time_to[i].focus(); return false;
      }
      return true;
  }

  function check_item_empty(i) {
    v_booking_facilities =
trim(document.bform.wv_booking_facilities[i].value);
    if ((document.bform.wv_booking_date[i].options.selectedIndex == 0) &&
         (document.bform.wv_booking_place[i].options.selectedIndex == 0) &&
         (document.bform.wv_booking_time_from[i].options.selectedIndex == 0)
&&
         (document.bform.wv_booking_time_to[i].options.selectedIndex == 0)
&&
         (!document.bform.chk_booking_light[i].checked) &&
         (!document.bform.chk_booking_air[i].checked) &&
         (v_booking_facilities.length == 0)) {
        return true;
    } else {
      return false;
    }
  }

  function check_item_duplication(i) {
    v_booking_date = trim(document.bform.wv_booking_date[i].value);
    v_booking_place = trim(document.bform.wv_booking_place[i].value);
    v_booking_time_from =
trim(document.bform.wv_booking_time_from[i].value);
    v_booking_time_to = trim(document.bform.wv_booking_time_to[i].value);
    for (j = 0; j < i; j++) {
      v_temp_booking_date = trim(document.bform.wv_booking_date[j].value);
      v_temp_booking_place = trim(document.bform.wv_booking_place[j].value);
      v_temp_booking_time_from =
trim(document.bform.wv_booking_time_from[j].value);
      v_temp_booking_time_to =
trim(document.bform.wv_booking_time_to[j].value);
      if ((v_booking_date == v_temp_booking_date) && (v_booking_place ==
v_temp_booking_place)) {
        if (parseInt(v_booking_time_from) >=
parseInt(v_temp_booking_time_from) &&
            parseInt(v_booking_time_from) <
parseInt(v_temp_booking_time_to)) {
          alert("Booking time (FROM) of booking item " + (parseInt(i) + 1) +
                " overlaps with booking item " + (parseInt(j)+ 1) + ".");
          document.bform.wv_booking_time_from[i].focus();
          return true;
        }
        if (parseInt(v_booking_time_to) > parseInt(v_temp_booking_time_from)
&&
            parseInt(v_booking_time_to) <= parseInt(v_temp_booking_time_to))
{
          alert("Booking time (TO) of booking item " + (parseInt(i) + 1) +
                " overlaps with booking item " + (parseInt(j)+ 1) + ".");
          document.bform.wv_booking_time_to[i].focus();
          return true;
        }
        if (parseInt(v_booking_time_from) <
parseInt(v_temp_booking_time_from) &&
            parseInt(v_booking_time_to) > parseInt(v_temp_booking_time_to))
{
          alert("The booking time span of booking item " + (parseInt(i) + 1)
+
                " overlaps with booking item " + (parseInt(j)+ 1) + ".");
          document.bform.wv_booking_time_from[i].focus();
          return true;
        }
      }
    }
    return false;
  }


  function check_item_hour_over_limit(i) {

    v_booking_date = trim(document.bform.wv_booking_date[i].value);
    v_booking_time_from =
trim(document.bform.wv_booking_time_from[i].value);
    v_booking_time_to = trim(document.bform.wv_booking_time_to[i].value);
    v_booking_time_duration = parseInt(v_booking_time_to) -
parseInt(v_booking_time_from);
    v_tot_booking_time_duration = 0;
    for (j = 0; j <= i; j++) {
      v_temp_booking_date = trim(document.bform.wv_booking_date[j].value);
      if (v_booking_date == v_temp_booking_date) {
        v_temp_booking_time_from =
trim(document.bform.wv_booking_time_from[j].value);
        v_temp_booking_time_to =
trim(document.bform.wv_booking_time_to[j].value);
        v_temp_booking_time_duration = parseInt(v_temp_booking_time_to) -
parseInt(v_temp_booking_time_from);
        v_tot_booking_time_duration += v_temp_booking_time_duration;
        if (parseInt(v_tot_booking_time_duration) >
parseInt(C_BOOKING_HOUR_LIMIT)) {
        alert("To achieve fair allocation for CDUM facilities, " +
              "you are only allowed to book maximum " + C_BOOKING_HOUR_LIMIT
+ " hours for any complexes in a day. " +
              "However, you intended to book " + v_tot_booking_time_duration
+ " hours on the date " + v_booking_date + ". " +
              "For details, please refer to the regulations listed in the
Booking Instruction.");
        document.bform.wv_booking_date[i].focus();
        return true;
      }
     }
   }
   return false;
  }


  function clear_booking_item(i) {
 document.bform.wv_booking_date[i].options.selectedIndex = 0;
 document.bform.wv_booking_place[i].options.selectedIndex = 0;
 document.bform.wv_booking_time_from[i].options.selectedIndex = 0;
 document.bform.wv_booking_time_to[i].options.selectedIndex =0;
 document.bform.chk_booking_light[i].checked = false;
 document.bform.chk_booking_air[i].checked = false;
 document.bform.wv_booking_facilities[i].value = "";
  document.bform.chk_booking_light[i].disabled=false;
  document.bform.chk_booking_air[i].disabled=false;
  }

 function popup_input_form(i) {
  isValid = true;
 if (document.bform.wv_booking_date[i].options.selectedIndex == 0)
 {
  alert("To use this function, please select Booking Date and Booking Place
first.");
  document.bform.wv_booking_date[i].focus();
  isValid = false;
 }
 if (isValid) {
  if ( document.bform.wv_booking_place[i].options.selectedIndex == 0)
  {
  alert("To use this function, please fill in Booking Date and Booking Place
first.");
  document.bform.wv_booking_place[i].focus();
  isValid = false;
  }
  if (isValid) {
   sURL = "CDW234_WebBookingNewDtlInput.jsp?";
   sURL += "wv_CheckDate=" + trim(document.bform.wv_booking_date[i].value);
   sURL += "&wv_CheckPlace=" +
trim(document.bform.wv_booking_place[i].value);
   sURL += "&wv_item_index=" + i;
   TimetableEnqResultwin=window.open(sURL,'TimetableEnqResult',"width=630,
height=200, resize=no");
  }
 }
 }

 function init() {
  // Check Facility existence
 for (var i=0; i < C_ITEM_NO; i++) {
  if (document.bform.wv_booking_place[i].options.selectedIndex != 0) {
   check_facility_existence(i);
  }
 }
 }

</script>


<form  method="post" name="bform" action="CDW230_WebBookingNewServlet" >
   <!-- Item 1 -->

   <select name=wv_booking_date>
      <option value = '' selected>--</option>
      <option value='07/07/2003' >07/07/2003(MON)</option>
      <option value='08/07/2003' >08/07/2003(TUE)</option>
      <option value='09/07/2003' >09/07/2003(WED)</option>
      <option value='10/07/2003' >10/07/2003(THU)</option>
      <option value='11/07/2003' >11/07/2003(FRI)</option>
      <option value='12/07/2003' >12/07/2003(SAT)</option>
      <option value='13/07/2003' >13/07/2003(SUN)</option>
      <option value='14/07/2003' >14/07/2003(MON)</option>
      <option value='15/07/2003' >15/07/2003(TUE)</option>
      <option value='16/07/2003' >16/07/2003(WED)</option>
      <option value='17/07/2003' >17/07/2003(THU)</option>
      <option value='18/07/2003' >18/07/2003(FRI)</option>
      <option value='19/07/2003' >19/07/2003(SAT)</option>
      <option value='20/07/2003' >20/07/2003(SUN)</option>
      <option value='21/07/2003' >21/07/2003(MON)</option>
   </select>

   <select name=wv_booking_place>
      <option value = '' selected>--</option>
      <option value = 'PAV' >PAVILION</option>
   </select>


   <select name=wv_booking_time_from>
      <option value = '' selected>--</option>
      <option value='8' >8:00</option>
      <option value='9' >9:00</option>
      <option value='10' >10:00</option>
      <option value='11' >11:00</option>
      <option value='12' >12:00</option>
      <option value='13' >13:00</option>
      <option value='14' >14:00</option>
      <option value='15' >15:00</option>
      <option value='16' >16:00</option>
      <option value='17' >17:00</option>
      <option value='18' >18:00</option>
      <option value='19' >19:00</option>
      <option value='20' >20:00</option>
      <option value='21' >21:00</option>
   </select>

   <select name=wv_booking_time_to>
      <option value = '' selected>--</option>
      <option value='9' >9:00</option>
      <option value='10' >10:00</option>
      <option value='11' >11:00</option>
      <option value='12' >12:00</option>
      <option value='13' >13:00</option>
      <option value='14' >14:00</option>
      <option value='15' >15:00</option>
      <option value='16' >16:00</option>
      <option value='17' >17:00</option>
      <option value='18' >18:00</option>
      <option value='19' >19:00</option>
      <option value='20' >20:00</option>
      <option value='21' >21:00</option>
      <option value='22' >22:00</option>
   </select>

   <input type="hidden" name=wv_booking_light value="">
   <input type="checkbox" name=chk_booking_light  >


   <input type="hidden" name=wv_booking_air value="">
   <input type="checkbox" name=chk_booking_air  >

   <input type="text" name="wv_booking_facilities" values="soccer">

   <input type="button" value="Clear" name="btnClear">



   <!-- Item 2 -->

   <select name=wv_booking_date>
      <option value = '' selected>--</option>
      <option value='07/07/2003' >07/07/2003(MON)</option>
      <option value='08/07/2003' >08/07/2003(TUE)</option>
      <option value='09/07/2003' >09/07/2003(WED)</option>
      <option value='10/07/2003' >10/07/2003(THU)</option>
      <option value='11/07/2003' >11/07/2003(FRI)</option>
      <option value='12/07/2003' >12/07/2003(SAT)</option>
      <option value='13/07/2003' >13/07/2003(SUN)</option>
      <option value='14/07/2003' >14/07/2003(MON)</option>
      <option value='15/07/2003' >15/07/2003(TUE)</option>
      <option value='16/07/2003' >16/07/2003(WED)</option>
      <option value='17/07/2003' >17/07/2003(THU)</option>
      <option value='18/07/2003' >18/07/2003(FRI)</option>
      <option value='19/07/2003' >19/07/2003(SAT)</option>
      <option value='20/07/2003' >20/07/2003(SUN)</option>
      <option value='21/07/2003' >21/07/2003(MON)</option>
   </select>

   <select name=wv_booking_place>
      <option value = '' selected>--</option>
      <option value = 'PAV' >PAVILION</option>
   </select>


   <select name=wv_booking_time_from>
      <option value = '' selected>--</option>
      <option value='8' >8:00</option>
      <option value='9' >9:00</option>
      <option value='10' >10:00</option>
      <option value='11' >11:00</option>
      <option value='12' >12:00</option>
      <option value='13' >13:00</option>
      <option value='14' >14:00</option>
      <option value='15' >15:00</option>
      <option value='16' >16:00</option>
      <option value='17' >17:00</option>
      <option value='18' >18:00</option>
      <option value='19' >19:00</option>
      <option value='20' >20:00</option>
      <option value='21' >21:00</option>
   </select>

   <select name=wv_booking_time_to>
      <option value = '' selected>--</option>
      <option value='9' >9:00</option>
      <option value='10' >10:00</option>
      <option value='11' >11:00</option>
      <option value='12' >12:00</option>
      <option value='13' >13:00</option>
      <option value='14' >14:00</option>
      <option value='15' >15:00</option>
      <option value='16' >16:00</option>
      <option value='17' >17:00</option>
      <option value='18' >18:00</option>
      <option value='19' >19:00</option>
      <option value='20' >20:00</option>
      <option value='21' >21:00</option>
      <option value='22' >22:00</option>
   </select>

   <input type="hidden" name=wv_booking_light value="">
   <input type="checkbox" name=chk_booking_light  >


   <input type="hidden" name=wv_booking_air value="">
   <input type="checkbox" name=chk_booking_air  >

   <input type="text" name="wv_booking_facilities" values="soccer">

   <input type="button" value="Clear" name="btnClear">



   <!-- Item 3 -->

   <select name=wv_booking_date>
      <option value = '' selected>--</option>
      <option value='07/07/2003' >07/07/2003(MON)</option>
      <option value='08/07/2003' >08/07/2003(TUE)</option>
      <option value='09/07/2003' >09/07/2003(WED)</option>
      <option value='10/07/2003' >10/07/2003(THU)</option>
      <option value='11/07/2003' >11/07/2003(FRI)</option>
      <option value='12/07/2003' >12/07/2003(SAT)</option>
      <option value='13/07/2003' >13/07/2003(SUN)</option>
      <option value='14/07/2003' >14/07/2003(MON)</option>
      <option value='15/07/2003' >15/07/2003(TUE)</option>
      <option value='16/07/2003' >16/07/2003(WED)</option>
      <option value='17/07/2003' >17/07/2003(THU)</option>
      <option value='18/07/2003' >18/07/2003(FRI)</option>
      <option value='19/07/2003' >19/07/2003(SAT)</option>
      <option value='20/07/2003' >20/07/2003(SUN)</option>
      <option value='21/07/2003' >21/07/2003(MON)</option>
   </select>

   <select name=wv_booking_place>
      <option value = '' selected>--</option>
      <option value = 'PAV' >PAVILION</option>
   </select>


   <select name=wv_booking_time_from>
      <option value = '' selected>--</option>
      <option value='8' >8:00</option>
      <option value='9' >9:00</option>
      <option value='10' >10:00</option>
      <option value='11' >11:00</option>
      <option value='12' >12:00</option>
      <option value='13' >13:00</option>
      <option value='14' >14:00</option>
      <option value='15' >15:00</option>
      <option value='16' >16:00</option>
      <option value='17' >17:00</option>
      <option value='18' >18:00</option>
      <option value='19' >19:00</option>
      <option value='20' >20:00</option>
      <option value='21' >21:00</option>
   </select>

   <select name=wv_booking_time_to>
      <option value = '' selected>--</option>
      <option value='9' >9:00</option>
      <option value='10' >10:00</option>
      <option value='11' >11:00</option>
      <option value='12' >12:00</option>
      <option value='13' >13:00</option>
      <option value='14' >14:00</option>
      <option value='15' >15:00</option>
      <option value='16' >16:00</option>
      <option value='17' >17:00</option>
      <option value='18' >18:00</option>
      <option value='19' >19:00</option>
      <option value='20' >20:00</option>
      <option value='21' >21:00</option>
      <option value='22' >22:00</option>
   </select>

   <input type="hidden" name=wv_booking_light value="">
   <input type="checkbox" name=chk_booking_light  >


   <input type="hidden" name=wv_booking_air value="">
   <input type="checkbox" name=chk_booking_air  >

   <input type="text" name="wv_booking_facilities" values="soccer">

   <input type="button" value="Clear" name="btnClear">


   <!-- SUBMIT -->

   <input type="reset" value="Clear All" name="reset">
   <input type="submit" value="Calculate Booking Fee" name="submit">

</form>

</BODY>
</HTML>
========================================================


Mime
View raw message