JSFiddle - React, Tailwind, and code Playground

by evon0306

HTML

<script src="https://kit.fontawesome.com/41e2a8dba7.js" crossorigin="anonymous"></script>

<label for="name">姓名:<input id="name" text="text"  placeholder="王小明"/></label>

<select name="gender" id="gender">
   <option value="none"selected disabled hidden>選擇服裝分類</option>
   <option value="male">男裝</option>
   <option value="Female">女裝</option>
</select>

<select name="clothing-type" id="clothing-type">
   <option value="none"selected disabled hidden>選擇服裝類型</option>
   <option value="coat">外套</option>
   <option value="Top">上衣</option>
   <option value="Bottom">下身</option>
</select>

<button class="order" onclick="order()">
   <i class="fa-regular fa-pen-to-square"></i>
   <div>我要訂購</div>
</button>

<button class="industry" onclick="industry()">
   <i class="fa-solid fa-industry"></i>
   <div>認識工廠</div>
</button>

<div class="order-info">
   <h2>您的訂單</h2>
   <ul>
      <li>顧客姓名 :   <span id="customer-name"></span></li>
      <li>服裝分類 :   <span id="customer-gender"></span></li>
      <li>服裝類型 :   <span id="customer-clothing-type"></span></li>
   </ul>
</div>

CSS

* {
  padding: 0;
  margin: 0;
  box-sizing: border-box;
  border: none;
  list-style: none;
}

* li {
  padding: 10px 0;
}

* li span {
  padding: 10px 20;
  color: rgba(0, 99, 56, 0.859);
}

label {
  margin: 1rem;
  display: flex;
  align-items: center;
  font: 1.2em sans-serif;
  padding: 10px;
}

label #name {
  background-color: rgb(196, 196, 196);
  color: rgba(0, 99, 56, 0.859);
  font-size: 1.1em;
  width: 170px;
  border-radius: 5px;
  padding: 5px;
}

select {
  margin: -1rem 5.15rem 1.5rem;
  display: flex;
  flex-direction: row;
  font: 1em sans-serif;
  width: 170px;
}

button {
  height: 100px;
  width: 100px;
  padding: 1.2rem;
  margin-left: 1rem;
  border-radius: 50%;
  background-color: rgb(255, 255, 255);
  transition: all 0.3s ease;
  box-shadow: 0 0 7px rgba(0, 0, 0, 0.43);
}

button:hover {
  background-color: rgba(0, 99, 56, 0.859);
  color: white;
}

button i {
  font-size: 1.8rem;
  margin-bottom: 0.4rem;
}

button div {
  font: 1.3em sans-serif;
}

.order {
  margin-left: 2.5rem;
}

.industry {
  margin-right: 2.5rem;
}

.order-info {
  margin: 1rem;
  padding: 10px;
  width: 60%;
}

.order-info h2 {
  border-bottom: 1px solid rgb(196, 196, 196);
}

JavaScript

function order()
{
  var name = document.getElementById('name').value;

 	var gender = document.getElementById('gender');
  var genderIndex = gender.selectedIndex;
 /*  var genderValue = gender.options[genderIndex].value; */
  var genderText = gender.options[genderIndex].text;


  var clothingType = document.getElementById('clothing-type');
  var TypeIndex = clothingType.selectedIndex;
 /*  var TypeValue = gender.options[TypeIndex].value; */
  var TypeText = clothingType.options[TypeIndex].text;
 
  alert(name+"您好!謝謝您對我們的衣服有興趣!請致電 0987-654-321,會有專人提供您報價!");
  document.getElementById('customer-name').textContent = name;
  document.getElementById('customer-gender').textContent = genderText;
  document.getElementById('customer-clothing-type').textContent = TypeText;
}

function industry()
{
  alert('我們工廠位於新北市,通過國際 ISO9001 認證,品質讓您放心!');
}