选择单选按钮时,表单应显示而无需重新加载页面
嗨,我是一名业余程序员。我想让表单动态显示,而无需在用户单击单选按钮后重新加载页面。有什么可以参考的吗?有人可以帮我解决这个问题吗?
这是 HTML 代码
<p>First Name: <input type="text" name="fname" size="15" maxlength="20"/> </p>
<p>Term <select name="term">
<option value="noterm">No Term</option>
<option value="1year">1 Year</option>
</select></p>
<p>Enter IMEI: <input type="text" name="imei" size="15" maxlength="20" value=""/> </p>
<p>Selling Price: <input type="text" name="sprice" size="15" maxlength="20" value=""/> </p>
<p>Rep: <input type="text" name="rep" size="5" maxlength="3" value=""/> </p>
<p><input type="submit"name="submit" value="Tender" /></p>
</form>
<!--This is where I need the action to HAPPEN-->
<form>
<input type="radio" name="Credit" value="ISC" /> ISC<br />
<input type="text" name="credit1" size="15" maxlength="10" value=""/>
</form>
Hi I am an amateur programmer. I want to have the form appear dynamically without reloading the page once user clicks the radio button. Is there any reference I can find. Can someone help me with this please.
Here's the HTML code
<p>First Name: <input type="text" name="fname" size="15" maxlength="20"/> </p>
<p>Term <select name="term">
<option value="noterm">No Term</option>
<option value="1year">1 Year</option>
</select></p>
<p>Enter IMEI: <input type="text" name="imei" size="15" maxlength="20" value=""/> </p>
<p>Selling Price: <input type="text" name="sprice" size="15" maxlength="20" value=""/> </p>
<p>Rep: <input type="text" name="rep" size="5" maxlength="3" value=""/> </p>
<p><input type="submit"name="submit" value="Tender" /></p>
</form>
<!--This is where I need the action to HAPPEN-->
<form>
<input type="radio" name="Credit" value="ISC" /> ISC<br />
<input type="text" name="credit1" size="15" maxlength="10" value=""/>
</form>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最简单的方法是为您的
radio
输入和隐藏的text
输入提供id
,然后使用以下 JavaScript:您将需要最初隐藏文本
input
,您可以在 CSS 中使用display:none
来完成此操作。您可以在此处查看示例。如果您能够使用 jQuery,那就更容易了,无需将
id
添加到您的input
元素,假设您的name
属性是唯一的:The easiest way will be to give your
radio
input and the hiddentext
input anid
, and then use the following JavaScript:You will need to hide the text
input
initially, which you can do from in your CSS withdisplay:none
. You can see an example of that here.If you are able to use jQuery it will be even easier, without adding an
id
to yourinput
elements, assuming yourname
attributes are unique: