2024.9.19(週四)

记得关月亮發表於2024-09-22

主任測試連線hadoop,以下是我完成增的部分的核心程式碼

<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>技術需求徵集填報</title>
  <style>
    body {
      font-family: Arial, sans-serif;
      margin: 20px;
      padding: 20px;
      border: 1px solid #ccc;
      border-radius: 5px;
      background-color: #f9f9f9;
    }
    h2 {
      color: #333;
    }
    label {
      display: block;
      margin: 10px 0 5px;
    }
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    input[type="number"],
    textarea,
    select {
      width: 100%;
      padding: 8px;
      margin-bottom: 15px;
      border: 1px solid #ccc;
      border-radius: 4px;
    }
    input[type="radio"],
    input[type="checkbox"] {
      margin-right: 10px;
    }
    .section {
      margin-bottom: 20px;
    }
    .button-container {
      display: flex;
      justify-content: space-between;
    }
  </style>
</head>
<body>
<h2>河北省重大技術需求徵集</h2>
<form action="submit.jsp" method="post">
  <div class="section">
    <label for="institutionName">機構全稱:</label>
    <input type="text" id="institutionName" name="institutionName" required>

    <label for="department">歸口管理部門:</label>
    <input type="text" id="department" name="department">

    <label for="address">通訊地址:</label>
    <input type="text" id="address" name="address" required>

    <label for="region">所在地域:</label>
    <input type="text" id="region" name="region" required>

    <label for="email">電子信箱:</label>
    <input type="email" id="email" name="email" required>

    <label for="representative">法人代表:</label>
    <input type="text" id="representative" name="representative">

    <label for="postalCode">郵政編碼:</label>
    <input type="text" id="postalCode" name="postalCode">

    <label for="contactPerson">聯絡人:</label>
    <input type="text" id="contactPerson" name="contactPerson">

    <label for="phoneFixed">電話 (固定):</label>
    <input type="tel" id="phoneFixed" name="phoneFixed">

    <label for="phoneMobile">電話 (手機):</label>
    <input type="tel" id="phoneMobile" name="phoneMobile">

    <label for="fax">傳真:</label>
    <input type="tel" id="fax" name="fax">
  </div>

  <div class="section">
    <label>機構屬性:</label>
    <input type="radio" id="enterprise" name="institutionType" value="企業">企業
    <input type="radio" id="college" name="institutionType" value="高等院校">高等院校
    <input type="radio" id="research" name="institutionType" value="研究機構">研究機構
    <input type="radio" id="other" name="institutionType" value="其他">其他
  </div>

  <div class="section">
    <label for="introduction">機構簡介:</label>
    <textarea id="introduction" name="introduction" rows="4" cols="50"></textarea>

    <label for="techNeedName">技術需求名稱:</label>
    <input type="text" id="techNeedName" name="techNeedName" required>

    <label for="deadline">需求時限:</label>
    <input type="text" id="deadline" name="deadline">

    <label for="techOverview">技術需求概述:</label>
    <textarea id="techOverview" name="techOverview" rows="4" cols="50"></textarea>

    <label for="mainProblem">主要問題:</label>
    <textarea id="mainProblem" name="mainProblem" rows="4" cols="50"></textarea>

    <label for="techKey">技術關鍵:</label>
    <textarea id="techKey" name="techKey" rows="4" cols="50"></textarea>

    <label for="expectedGoal">預期目標:</label>
    <textarea id="expectedGoal" name="expectedGoal" rows="4" cols="50"></textarea>

    <label for="keywords">關鍵字:</label>
    <input type="text" id="keywords" name="keywords">

    <label for="investment">擬投入資金總額 (萬元):</label>
    <input type="number" id="investment" name="investment" step="0.01">
  </div>

  <div class="section">
    <label>技術需求解決方式:</label>
    <input type="radio" id="independent" name="solutionMethod" value="獨立研發">獨立研發
    <input type="radio" id="commission" name="solutionMethod" value="委託研發">委託研發
    <input type="radio" id="cooperation" name="solutionMethod" value="合作研發">合作研發
    <input type="radio" id="otherMethod" name="solutionMethod" value="其他">其他
  </div>

  <div class="section">
    <label for="cooperationIntent">合作意向單位:</label>
    <input type="text" id="cooperationIntent" name="cooperationIntent">
  </div>

  <div class="section">
    <label>科技活動型別:</label>
    <input type="radio" id="basicResearch" name="techActivityType" value="基礎研究">基礎研究
    <input type="radio" id="appliedResearch" name="techActivityType" value="應用研究">應用研究
    <input type="radio" id="experimentDevelopment" name="techActivityType" value="試驗發展">試驗發展
    <input type="radio" id="resultApplication" name="techActivityType" value="研究與試驗發展成果應用">研究與試驗發展成果應用
    <input type="radio" id="techPromotion" name="techActivityType" value="技術推廣與科技服務">技術推廣與科技服務
    <input type="radio" id="productiveActivity" name="techActivityType" value="生產性活動">生產性活動
  </div>

  <div class="section">
    <%--@declare id="discipline"--%><label for="discipline">學科分類:</label>
    <select id="firstDiscipline" name="firstDiscipline" onchange="loadSecondLevel1(this.value, 'secondDiscipline', 'disciplineValue')">
      <option value="">請選擇第一級</option>
      <option value="science">理科</option>
      <option value="engineering">工科</option>
      <!-- 其他第一級分類 -->
    </select>

    <select id="secondDiscipline" name="secondDiscipline" onchange="loadThirdLevel1(this.value, 'thirdDiscipline', 'disciplineValue')">
      <option value="">請選擇第二級</option>
    </select>

    <select id="thirdDiscipline" name="thirdDiscipline">
      <option value="">請選擇第三級</option>
    </select>

    <input type="hidden" id="disciplineValue" name="disciplineValue">
  </div>

  <div class="section">
    <label>需求技術所屬領域:</label>
    <input type="checkbox" id="electronic" name="techField" value="電子資訊">電子資訊
    <input type="checkbox" id="mechatronics" name="techField" value="光機電一體化">光機電一體化
    <input type="checkbox" id="biotech" name="techField" value="生物技術與製藥">生物技術與製藥
    <!-- 這裡可以新增其他領域的核取方塊 -->
  </div>

  <div class="section">
    <label>需求技術應用行業:</label>
    <select id="firstIndustry" name="firstIndustry" onchange="loadSecondLevel(this.value, 'secondIndustry', 'industryValue')">
      <option value="">請選擇第一級</option>
      <option value="manufacturing">製造業</option>
      <option value="service">服務業</option>
      <!-- 其他第一級分類 -->
    </select>

    <select id="secondIndustry" name="secondIndustry" onchange="loadThirdLevel(this.value, 'thirdIndustry', 'industryValue')">
      <option value="">請選擇第二級</option>
    </select>

    <select id="thirdIndustry" name="thirdIndustry">
      <option value="">請選擇第三級</option>
    </select>

    <input type="hidden" id="industryValue" name="industryValue">
  </div>

  <div class="button-container">
    <a href="result.jsp">跳轉1</a>
    <a href="search.jsp">跳轉2</a>
    <input type="submit" value="提交">
  </div>
</form>
<script>
  function loadSecondLevel1(firstLevelValue, secondLevelId, hiddenInputId) {
    var secondLevelSelect = document.getElementById(secondLevelId);
    secondLevelSelect.innerHTML = ''; // 清除現有選項
    var defaultOption = document.createElement("option");
    defaultOption.value = "";
    defaultOption.text = "請選擇第二級";
    secondLevelSelect.appendChild(defaultOption);

    // 根據firstLevelValue設定第二級選項
    if(firstLevelValue === "science") {
      var option1 = document.createElement("option");
      option1.value = "mathematics";
      option1.text = "數學";
      secondLevelSelect.appendChild(option1);
    } else if(firstLevelValue === "engineering") {
      var option2 = document.createElement("option");
      option2.value = "civil_engineering";
      option2.text = "土木工程";
      secondLevelSelect.appendChild(option2);
    }
  }

  function loadThirdLevel1(secondLevelValue, thirdLevelId, hiddenInputId) {
    var thirdLevelSelect = document.getElementById(thirdLevelId);
    thirdLevelSelect.innerHTML = ''; // 清除現有選項
    var defaultOption = document.createElement("option");
    defaultOption.value = "";
    defaultOption.text = "請選擇第三級";
    thirdLevelSelect.appendChild(defaultOption);

    // 根據secondLevelValue設定第三級選項
    if(secondLevelValue === "mathematics") {
      var option1 = document.createElement("option");
      option1.value = "applied_mathematics";
      option1.text = "應用數學";
      thirdLevelSelect.appendChild(option1);
    } else if(secondLevelValue === "civil_engineering") {
      var option2 = document.createElement("option");
      option2.value = "structural_engineering";
      option2.text = "結構工程";
      thirdLevelSelect.appendChild(option2);
    }
  }

  // 當第三級下拉框選項變化時,更新隱藏輸入框的值
  document.getElementById('thirdDiscipline').addEventListener('change', function() {
    var hiddenInput = document.getElementById('disciplineValue');
    hiddenInput.value = document.getElementById('firstDiscipline').value + ' > ' +
            document.getElementById('secondDiscipline').value + ' > ' +
            this.value;
  });
  // 載入第二級分類的函式
  function loadSecondLevel(firstLevelValue, secondLevelId, hiddenInputId) {
    var secondLevelSelect = document.getElementById(secondLevelId);
    secondLevelSelect.innerHTML = ''; // 清除現有選項
    var defaultOption = document.createElement("option");
    defaultOption.value = "";
    defaultOption.text = "請選擇第二級";
    secondLevelSelect.appendChild(defaultOption);

    // 根據firstLevelValue設定第二級選項
    switch(firstLevelValue) {
      case "manufacturing":
        var option1 = document.createElement("option");
        option1.value = "heavy_industry";
        option1.text = "重工業";
        secondLevelSelect.appendChild(option1);

        var option2 = document.createElement("option");
        option2.value = "light_industry";
        option2.text = "輕工業";
        secondLevelSelect.appendChild(option2);
        break;
      case "service":
        var option3 = document.createElement("option");
        option3.value = "finance";
        option3.text = "金融業";
        secondLevelSelect.appendChild(option3);

        var option4 = document.createElement("option");
        option4.value = "education";
        option4.text = "教育業";
        secondLevelSelect.appendChild(option4);
        break;
    }
  }

  function loadThirdLevel(secondLevelValue, thirdLevelId, hiddenInputId) {
    var thirdLevelSelect = document.getElementById(thirdLevelId);
    thirdLevelSelect.innerHTML = ''; // 清除現有選項
    var defaultOption = document.createElement("option");
    defaultOption.value = "";
    defaultOption.text = "請選擇第三級";
    thirdLevelSelect.appendChild(defaultOption);

    // 根據secondLevelValue設定第三級選項
    switch(secondLevelValue) {
      case "heavy_industry":
        var option1 = document.createElement("option");
        option1.value = "steel";
        option1.text = "鋼鐵行業";
        thirdLevelSelect.appendChild(option1);

        var option2 = document.createElement("option");
        option2.value = "machinery";
        option2.text = "機械行業";
        thirdLevelSelect.appendChild(option2);
        break;
      case "light_industry":
        var option3 = document.createElement("option");
        option3.value = "food";
        option3.text = "食品行業";
        thirdLevelSelect.appendChild(option3);

        var option4 = document.createElement("option");
        option4.value = "textile";
        option4.text = "紡織行業";
        thirdLevelSelect.appendChild(option4);
        break;
      case "finance":
        var option5 = document.createElement("option");
        option5.value = "banking";
        option5.text = "銀行";
        thirdLevelSelect.appendChild(option5);

        var option6 = document.createElement("option");
        option6.value = "insurance";
        option6.text = "保險";
        thirdLevelSelect.appendChild(option6);
        break;
      case "education":
        var option7 = document.createElement("option");
        option7.value = "primary";
        option7.text = "基礎教育";
        thirdLevelSelect.appendChild(option7);

        var option8 = document.createElement("option");
        option8.value = "higher";
        option8.text = "高等教育";
        thirdLevelSelect.appendChild(option8);
        break;
    }
  }

  // 當第三級下拉框選項變化時,更新隱藏輸入框的值
  document.getElementById('thirdIndustry').addEventListener('change', function() {
    var hiddenInput = document.getElementById('industryValue');
    hiddenInput.value = document.getElementById('firstIndustry').value + ' > ' +
            document.getElementById('secondIndustry').value + ' > ' +
            this.value;
  });
</script>
</body>
</html>

相關文章