我想建立一个表单,用户可以从一组单选按钮中进行选择,如果他们不喜欢任何选择,他们可以使用最后一个单选按钮,该按钮将有一个文本字段,他们可以在其中输入自定义文本。
我在几个网站上看到过这个。只是想知道它是在哪里以及如何实现的
最佳答案
我给你举个例子,这是你想要的吗? http://www.jsfiddle.net/T7gE7/
var temp = '';
function disableTxt() {
var field = document.getElementById("other");
if(field.value != '') {
temp = field.value;
}
field.style.display = "none";
field.value = '';
}
function enableTxt() {
document.getElementById("other").style.display = "inline";
document.getElementById("other").value = temp;
}
关于html - 单选按钮和输入字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4322758/