Json 入门例子(form表单)【0】

本文介绍了一个使用JavaScript实现的表单序列化与解码的功能。通过点击按钮可以显示表单数据,其中包括文本输入、选择框等元素的值。此外,还提供了一个简单的表单用于演示。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<script>
        $(function () {
     var aa = $("#fm").serialize().replace(/\+/g, "");
     var ac = decodeURIComponent(aa);
     $("#fm").click(function () {
            alert(ac);
           });

        });

    </script>

    <form id="form1" name="form1" method="post" action="">
        <p>
            进货人 :
            <label for="name"></label>
            <input type="text" name="name" id="name" />
        </p>
        <p>
            性别:
            <label for="sex"></label>
            <select name="sex" size="1" id="sex">
                <option value="1">男</option>
                <option value="2">女</option>
            </select>
        </p>
        <table width="708" border="1">
            <tr>
                <td width="185">商品名</td>
                <td width="205">商品数量</td>
                <td width="296">商品价格</td>
            </tr>
            <tr>
                <td>
                    <label for="pro_name"></label>
                    <input type="text" name="pro_name" id="pro_name" />
                </td>
                <td>
                    <label for="pro_num"></label>
                    <input type="text" name="pro_num" id="pro_num" />
                </td>
                <td>
                    <label for="pro_price"></label>
                    <input type="text" name="pro_price" id="pro_price" />
                </td>
            </tr>
            <tr>
                <td><input type="text" name="pro_name2" id="pro_name2" /></td>
                <td><input type="text" name="pro_num2" id="pro_num2" /></td>
                <td><input type="text" name="pro_price2" id="pro_price2" /></td>
            </tr>
        </table>
        <p> </p>
        <input type="button" name="submit" onclick="onClik();" value="提交" />
    </form>
    <form id="fm">

        <input type="text" name="username" value="zhangsan" /><br /><br />
        <input type="text" name="age" value="12" /><br /><br />
        <input type="text" name="address" value="北京  朝阳" /><br /><br />
        <input type="text" name="job" value="IT" /><br /><br />
        <textarea name="content">abc + 123 + 456  </textarea>
        <input type="button" value="发送" onclick="add()" /><br /><br />


    </form> 

  

 

转载于:https://www.cnblogs.com/laopo/p/4757260.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值