我必须附加到HTML表单中的单选按钮的文本输入区域如下所示:HTML表单输入 - 选择
<fieldset class="w100">
<div class="rowElem align-left">
<input type="radio" id="plan_height" name="plan_height" value="standard6'2"" checked >
<label>Standard 6'2"</label>
</div>
<div class="rowElem align-left">
<input type="radio" id="other_text" name="plan_height" value="Other height" onclick="document.getElementById('other_height').focus();" >
<input type="text" id="other_height" name="plan_height" value="Enter custom height" onFocus="if(this.value=='Enter custom height') this.value='';" onBlur="if(this.value=='') this.value='Enter custom height';">
<label for="other_text">Other</label>
</div>
</fieldset>
如果用户的“其他选择第二个单选选项, “我希望文本框自动对焦,让他们输入一个值。另外,如果用户单击文本框输入值,我希望单选按钮可以自动为它们选择此选项。
我试过在窗体元素上使用onBlur或onChange或onKeyup,但似乎无法让它工作。
你开到使用jQuery ? – 2012-03-05 17:26:02
当然,但如果可能的话,我想保持它更简单,只需包含在onKeyup或onChange表单事件中。 – adamdehaven 2012-03-05 17:26:53
你能告诉你如何尝试使用onBlur/onChange/onKeyup吗?另外,您是否可以确认第一个无线电控制的ID和值? – 2012-03-05 17:27:06