From 3984124b17f90e1b9efe520f9eaca47791f93d16 Mon Sep 17 00:00:00 2001 From: fdzcxy212207113 <2335228773@qq.com> Date: Thu, 10 Oct 2024 14:17:58 +0800 Subject: [PATCH 1/4] Initial commit --- README.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..2fb13da --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# jhj_yzw + -- 2.34.1 From 4f3af598154f9afa3e9c1c446771dc2ce337a9b5 Mon Sep 17 00:00:00 2001 From: YYY <2972190247@qq.com> Date: Thu, 10 Oct 2024 15:11:12 +0800 Subject: [PATCH 2/4] html --- index.html | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 index.html diff --git a/index.html b/index.html new file mode 100644 index 0000000..5c006e3 --- /dev/null +++ b/index.html @@ -0,0 +1,29 @@ + + + + +Base Converter + + + +
+

进制转换器

+
+ + + + + + + + + + +
+ +
+
+ + + + \ No newline at end of file -- 2.34.1 From 3c1eb19d67862d63eefd0ddee9c551664bfb19d2 Mon Sep 17 00:00:00 2001 From: YYY <2972190247@qq.com> Date: Thu, 10 Oct 2024 15:12:26 +0800 Subject: [PATCH 3/4] css --- styles.css | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 styles.css diff --git a/styles.css b/styles.css new file mode 100644 index 0000000..277a0e1 --- /dev/null +++ b/styles.css @@ -0,0 +1,25 @@ +body { + font-family: Arial, sans-serif; +} + +.container { + width: 300px; + margin: 50px auto; + padding: 20px; + border: 1px solid #ccc; + border-radius: 5px; +} + +form { + display: flex; + flex-direction: column; +} + +label, input, button { + margin: 5px 0; +} + +#result { + margin-top: 20px; + font-weight: bold; +} \ No newline at end of file -- 2.34.1 From f6af9138ddb8394fd82f9fdc74121653b7fefce3 Mon Sep 17 00:00:00 2001 From: jhj <2335228773@qq.com> Date: Thu, 10 Oct 2024 19:32:53 +0800 Subject: [PATCH 4/4] script.js --- script.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 script.js diff --git a/script.js b/script.js new file mode 100644 index 0000000..7efc9cc --- /dev/null +++ b/script.js @@ -0,0 +1,15 @@ +document.getElementById('converterForm').addEventListener('submit', function(event) { + event.preventDefault(); // 阻止表单默认提交行为 + + const inputValue = document.getElementById('inputValue').value.toUpperCase(); + const fromBase = parseInt(document.getElementById('fromBase').value, 10); + const toBase = parseInt(document.getElementById('toBase').value, 10); + + try { + const decimalValue = parseInt(inputValue, fromBase); + const result = decimalValue.toString(toBase).toUpperCase(); + document.getElementById('result').textContent = `转换后的数值:${result} (${toBase}进制)`; + } catch (e) { + document.getElementById('result').textContent = '转换错误,请检查输入是否正确'; + } +}); \ No newline at end of file -- 2.34.1