One Hat Cyber Team
Your IP :
3.144.230.138
Server IP :
50.28.103.30
Server :
Linux host.jcukjv-lwsites.com 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
Server Software :
nginx/1.24.0
PHP Version :
8.3.12
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
www
/
wwwroot
/
ef.electronharmony.com
/
1
/
T1
/
Edit File:
index1.html
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>基于数据类型动态生成输入框</title> <style> body { font-family: Arial, sans-serif; background-color: #f4f4f4; padding: 20px; } .container { max-width: 600px; margin: auto; padding: 20px; background-color: white; border-radius: 8px; box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); } h2 { text-align: center; margin-bottom: 20px; } label { font-weight: bold; margin-top: 10px; display: block; } input[type="text"], input[type="date"], input[type="email"] { width: 100%; padding: 8px; margin-top: 5px; border: 1px solid #ccc; border-radius: 4px; } button { margin-top: 20px; padding: 10px; width: 100%; background-color: #4CAF50; color: white; border: none; border-radius: 4px; cursor: pointer; } button:hover { background-color: #45a049; } .form-group { margin-bottom: 20px; } </style> </head> <body> <script> // 假设定义了几种基本数据类型 let dataTypes = []; // 根据数据类型生成输入框 function generateInputFields(types) { const formContainer = document.getElementById('formContainer'); formContainer.innerHTML = ''; // 清空之前的内容 types.forEach(field => { // 创建输入框的标签 const label = document.createElement('label'); label.textContent = field.label; formContainer.appendChild(label); // 创建输入框 const input = document.createElement('input'); input.setAttribute('type', field.type); if (field.placeholder) { input.setAttribute('placeholder', field.placeholder); } input.setAttribute('name', field.label); input.classList.add('form-group'); formContainer.appendChild(input); }); // 添加一个提交按钮 const submitButton = document.createElement('button'); submitButton.textContent = '提交'; submitButton.setAttribute('type', 'submit'); formContainer.appendChild(submitButton); } </script> </body> </html> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>模拟Google表单</title> <style> body { font-family: Arial, sans-serif; background-color: #f4f4f4; padding: 20px; } .container { max-width: 600px; margin: auto; padding: 20px; background-color: white; border-radius: 8px; box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); } h2 { text-align: center; margin-bottom: 20px; } label { font-weight: bold; margin-top: 10px; display: block; } input[type="text"], input[type="email"], input[type="date"] { width: 100%; padding: 8px; margin-top: 5px; border: 1px solid #ccc; border-radius: 4px; } .input-group { margin-bottom: 15px; } button { margin-top: 20px; padding: 10px; width: 100%; background-color: #4CAF50; color: white; border: none; border-radius: 4px; cursor: pointer; } button:hover { background-color: #45a049; } </style> </head> <body> <div class="container"> <h2>动态表单生成器</h2> <!-- 用户选择数据类型的部分 --> <div class="input-group"> <label for="fieldType">选择字段类型:</label> <select id="fieldType"> <option value="text">文字输入</option> <option value="email">电子邮件</option> <option value="date">日期</option> <option value="checkbox">多选框</option> </select> </div> <button id="addFieldBtn" class="btn btn-primary">添加字段</button> <!-- 动态生成的表单显示区域 --> <form id="dynamicForm" class="form-container"></form> </div> <script> // 选择元素 const fieldTypeSelect = document.getElementById('fieldType'); const addFieldBtn = document.getElementById('addFieldBtn'); const dynamicForm = document.getElementById('dynamicForm'); // 当点击“添加字段”时,动态生成相应的表单字段 addFieldBtn.addEventListener('click', function() { const selectedFieldType = fieldTypeSelect.value; // 创建一个新的字段容器 const fieldContainer = document.createElement('div'); fieldContainer.classList.add('input-group'); // 根据选择的字段类型生成相应的输入元素 if (selectedFieldType === 'text') { const label = document.createElement('label'); label.textContent = '文字输入:'; const input = document.createElement('input'); input.setAttribute('type', 'text'); input.setAttribute('placeholder', '输入文字'); input.setAttribute('name', 'textInput'); fieldContainer.appendChild(label); fieldContainer.appendChild(input); } else if (selectedFieldType === 'email') { const label = document.createElement('label'); label.textContent = '电子邮件:'; const input = document.createElement('input'); input.setAttribute('type', 'email'); input.setAttribute('placeholder', '输入电子邮件'); input.setAttribute('name', 'emailInput'); fieldContainer.appendChild(label); fieldContainer.appendChild(input); } else if (selectedFieldType === 'date') { const label = document.createElement('label'); label.textContent = '选择日期:'; const input = document.createElement('input'); input.setAttribute('type', 'date'); input.setAttribute('name', 'dateInput'); fieldContainer.appendChild(label); fieldContainer.appendChild(input); } else if (selectedFieldType === 'checkbox') { const label = document.createElement('label'); label.textContent = '选择选项:'; const checkbox1 = document.createElement('input'); checkbox1.setAttribute('type', 'checkbox'); checkbox1.setAttribute('name', 'option1'); checkbox1.setAttribute('value', '选项1'); const checkboxLabel1 = document.createElement('label'); checkboxLabel1.textContent = '选项1'; const checkbox2 = document.createElement('input'); checkbox2.setAttribute('type', 'checkbox'); checkbox2.setAttribute('name', 'option2'); checkbox2.setAttribute('value', '选项2'); const checkboxLabel2 = document.createElement('label'); checkboxLabel2.textContent = '选项2'; fieldContainer.appendChild(label); fieldContainer.appendChild(checkbox1); fieldContainer.appendChild(checkboxLabel1); fieldContainer.appendChild(checkbox2); fieldContainer.appendChild(checkboxLabel2); } // 将生成的字段添加到表单中 dynamicForm.appendChild(fieldContainer); }); </script> </body> </html>
Simpan