To create an HTML form for the provided data representing a chemical supply, you can structure the form to include appropriate input fields for each of the data properties. Here's an example of an HTML form that captures the given information:
HTML Form Example
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Chemical Supply Form</title>
<link rel="stylesheet" href="/bootstrap.css"> <!-- Include Bootstrap if needed -->
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
}
.form-container {
max-width: 600px;
margin: auto;
padding: 20px;
border: 1px solid #ddd;
border-radius: 5px;
box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.1);
}
.form-group {
margin-bottom: 15px;
}
label {
display: block;
margin-bottom: 5px;
}
input[type="text"], input[type="number"], input[type="submit"], select {
width: 100%;
padding: 8px;
font-size: 14px;
border: 1px solid #ddd;
border-radius: 4px;
}
input[type="submit"] {
background-color: #4CAF50;
color: white;
border: none;
cursor: pointer;
}
input[type="submit"]:hover {
background-color: #45a049;
}
</style>
</head>
<body>
<div class="form-container">
<h2>Chemical Supply Entry Form</h2>
<form action="/submit" method="POST"> <!-- Adjust action URL as needed -->
<div class="form-group">
<label for="chemical_name">Chemical Name</label>
<input type="text" id="chemical_name" name="chemical_name" value="Acetic Acid" required>
</div>
<div class="form-group">
<label for="vendor">Vendor</label>
<input type="text" id="vendor" name="vendor" value="Chemical Inc." required>
</div>
<div class="form-group">
<label for="density">Density (g/mL)</label>
<input type="number" id="density" name="density" step="0.01" value="1.05" required>
</div>
<div class="form-group">
<label for="viscosity">Viscosity (mPa·s)</label>
<input type="number" id="viscosity" name="viscosity" step="0.01" value="0.89" required>
</div>
<div class="form-group">
<label for="packaging">Packaging</label>
<input type="text" id="packaging" name="packaging" value="Bottle" required>
</div>
<div class="form-group">
<label for="pack_size">Pack Size</label>
<input type="number" id="pack_size" name="pack_size" value="500" required>
</div>
<div class="form-group">
<label for="unit">Unit</label>
<select id="unit" name="unit" required>
<option value="mL" selected>mL</option>
<option value="L">L</option>
<option value="g">g</option>
<option value="kg">kg</option>
<option value="m³">m³</option>
</select>
</div>
<div class="form-group">
<label for="quantity">Quantity</label>
<input type="number" id="quantity" name="quantity" value="100" required>
</div>
<input type="submit" value="Submit">
</form>
</div>
</body>
</html>
Key Features of the Form:
-
Input Fields: Each piece of data (chemical name, vendor, density, viscosity, packaging, pack size, unit, and quantity) has a corresponding input field where the user can enter or modify data.
-
Default Values: Each input contains a default value as per your JSON data.
-
Required Fields: The required attribute in the input fields ensures that the user cannot submit the form without filling out those fields.
-
Form Submission: The form uses the POST method to send data to a designated action URL, which you can modify according to your backend endpoint.
-
Styling: Basic styles are applied for layout and aesthetics. You can adjust these styles or incorporate frameworks like Bootstrap for more complexity.
How to Use This Form
- Copy the above code into an HTML file.
- Adjust the
action attribute of the <form> element to point to your server-side processing script (if applicable).
- Open the HTML file in a web browser to view and interact with the form.
This form provides a basic UI for adding or editing chemical supply data, which can be extended or modified as needed for your application.