这几天略忙没怎么折腾,今天研究了一下用select表单取值进行运算的方法,感觉JS版不是什么新鲜玩意儿,但PHP版本好像还没见人写过,所以一起写出来顺便除除草. 我是边吃饭边写的,写完我就吃完了,吃完我就出去了,最近没有时间一个个看评论,大概得等什么时候我状态
这几天略忙没怎么折腾,今天研究了一下用select表单取值进行运算的方法,感觉JS版不是什么新鲜玩意儿,但PHP版本好像还没见人写过,所以一起写出来顺便除除草.
我是边吃饭边写的,写完我就吃完了,吃完我就出去了,最近没有时间一个个看评论,大概得等什么时候我状态好点才会回复了吧.
希望你们还是那么深深的思念我.
PHP法
PHP需要通过$_POST
获取由表单提交传过来的值,所以需要点击按钮提交后才能实现运算,
效果如下:
JS法
JS法无需刷新页面,会实时显示结果
<script> function getResult(){ var number = document.formJs.xhdSelect.value;//获取select值 document.getElementById("result").innerHTML= number*2;//重写元素显示运算结果 } </script>效果如下:
原文地址:Selcect表单取值运算的两种方法, 感谢原作者分享。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 Chinese version
Chinese version, very easy to use

Notepad++7.3.1
Easy-to-use and free code editor

Dreamweaver Mac version
Visual web development tools
