У меня есть форма,расчистки текстового поля Форм, а также ввод
<form class="form-inline" role="form" method="post">
<div class="table-responsive">
<table>
<tr class="tr_top">
<td class="td_top"><textarea class="form-control" rows="4" name="msg" placeholder="Your message here." onfocus='this.select()'><?php
('encode.php');
require ('decode.php');
if (isset($_POST['encode'])) {
echo $encstring;
} elseif (isset($_POST['decode'])) {
echo $decstring;
} ?>
</textarea></td>
</tr>
<tr class="tr_mid">
<td class="td_mid">
<input type=text class="form-control input_mid" name="offset" value="<?php if (isset($_POST['encode']) || isset($_POST['decode'])) { echo htmlspecialchars($_POST['offset']);} ?>" placeholder="Enter a number." pattern="[0-9]{0,3}" oninvalid="setCustomValidity('Please enter a number between 1 and 999.')"></td>
</tr>
<tr class="tr_bottom">
<td class="td_bottom">
<input class="input_bottom btn btn-default" type="submit" name="encode" value="Encode">
<input class="input_bottom btn btn-default" type="submit" name="decode" value="Decode">
<input class="input_bottom btn btn-default" type="button" value="Clear" onclick='this.form.elements.msg.value=""'</td>
</tr>
</table>
</div><!-- close table-responsive -->
</form>
, где, при нажатии на входе со значением «Clear», я хочу, чтобы очистить как TEXTAREA и поле ввода в формах (имя = msg "и name =" offset ", соответственно). В настоящее время этот бит кода:
value="Clear" onclick='this.form.elements.msg.value=""'
только очищает поле textarea. Как я могу заставить их очистить? Я знаю, что это жестко запрограммировано, и когда я меняю его на onclick = 'this.form.elements.offset.value = "", то он работает для ввода. Как я могу его очистить сразу?
Где бы я поместил код? Прямо внутри входного тега? – winthropite
нет, в '