gpt4 book ai didi

javascript - 阻止表单将值推送到 url javascript

转载 作者:行者123 更新时间:2023-12-02 18:52:36 24 4
gpt4 key购买 nike

所以我有一个使用 html 和 javascript 制作的网络表单(我不是程序员),我找到了一些 CSS 代码,使它看起来很漂亮,但我必须重新做我的表单并给它不同的标签即( <label>, <p> <fieldset> )这不在我的原始代码中。现在我所有的document.affiliateForm.afc4.value= somevalue;语句不再写入其字段,而是推送到 url ( /index.html?somevalue=x&someothervalue=y )。有谁知道这可能是什么原因造成的?我非常确定这不是我的 JavaScript 造成的,因为在我更改这些标签之前一切都正常,并且推送到 url 的值都是正确的。

这里的任何帮助都会很棒

<fieldset>
<legend>How much can you make?</legend>
<form name="affiliateForm">
<p>
<label for="you">How many members will you refer:</label>
<input class="fixed" type="text" name="you">
</p>
<p>
<label for="them">How many members will they refer:</label>
<input class="fixed" type="text" name="them"><br />
</p>
<p class="nolabel">
<button onClick="calculateAffiliate()">Calculate Affiliate Amount</button>
</p>
<br>
<!-- End Entry Fields -->

<!-- Field Names -->
<p>
<label class="matrix">Levels:</label>
<input type="text" name="cst" value="Customer" value="Level" disabled>
<input type="text" name="com" value="Commission" value="Level" disabled>
<input type="text" name="afc" value="Affiliate Commision" value="Level" disabled>
<input type="text" name="pab" value="Platinum Affiliate Bonus" value="Level" disabled>
</p>
<!-- End Field Names -->
<!-- Start Level 1 -->
<p>
<label class="matrix">Level 1:</label>
<input type="text" name="cst1">
<input type="text" name="com1">
<input type="text" name="afc1">
<input type="text" name="pab1">
</p>
<!-- End Level 1 -->
<!-- Start Level 2 -->
<p>
<label class="matrix">Level 2:</label>
<input type="text" name="cst2">
<input type="text" name="com2">
<input type="text" name="afc2">
<input type="text" name="pab2">
</p>
<!-- End Level 2 -->
<!-- Start Level 3 -->
<p>
<label class="matrix">Level 3:</label>
<input type="text" name="cst3">
<input type="text" name="com3">
<input type="text" name="afc3">
<input type="text" name="pab3">
</p>
<!-- End Level 3 -->
<!-- Start Level 4 -->
<p>
<label class="matrix">Level 4:</label>
<input type="text" name="cst4">
<input type="text" name="com4">
<input type="text" name="afc4">
<input type="text" name="pab4">
</p>
<!-- End Level 4 -->
<!-- Start Level 5 -->
<p>
<label class="matrix">Level 5:</label>
<input type="text" name="cst5">
<input type="text" name="com5">
<input type="text" name="afc5">
<input type="text" name="pab5">
</p>
<!-- End Level 5 -->
<!-- Start Level 6 -->
<p>
<label class="matrix">Level 6:</label>
<input type="text" name="cst6">
<input type="text" name="com6">
<input type="text" name="afc6">
<input type="text" name="pab6">
</p>
<!-- End Level 6 -->
<!-- Start Level 7 -->
<p>
<label class="matrix">Level 7:</label>
<input type="text" name="cst7">
<input type="text" name="com7">
<input type="text" name="afc7">
<input type="text" name="pab7">
</p>
<!-- End Level 7 -->
<!-- Start Level 8 -->
<p>
<label class="matrix">Level 8:</label>
<input type="text" name="cst8">
<input type="text" name="com8">
<input type="text" name="afc8">
<input type="text" name="pab8">
</p>
<!-- End Level 8 -->
<!-- Start Level 9 -->
<p>
<label class="matrix">Level 9:</label>
<input type="text" name="cst9">
<input type="text" name="com9">
<input type="text" name="afc9">
<input type="text" name="pab9">
</p>
<!-- End Level 9 -->
<!-- Start Level 10 -->
<p>
<label class="matrix">Level 10:</label>
<input type="text" name="cst10">
<input type="text" name="com10">
<input type="text" name="afc10">
<input type="text" name="pab10">
</p>
<br>
<!-- End Level 10 -->

<!-- Totals -->
<p>
<label for="total1">Total Affiliate Commission:</label>
<input class="fixed" type="text" name="total1">
</p>
<p>
<label for="total2">Total Platinum Affiliate Bonus:</label>
<input class="fixed" type="text" name="total2">
</p>
<p>
<label for="total">Total Payout</label>
<input class="fixed" type="text" name="total">
</p>
<!-- End Totals -->

</fieldset>
</form>

编辑*****

我添加了建议的 method="POST",它确实阻止了代码显示在 URL 中,但它仍然从字段中消失。

最佳答案

如果您使用<form name="affiliateForm" method="POST">这些字段将不再被附加。如method="GET"是标准,如果您没有另外指定,字段将被推送到 url。

关于javascript - 阻止表单将值推送到 url javascript,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15670039/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com