我有一个Html表单,在发送数据之后,我有一项任务是保留用户输入的信息,而不是清理表单。表格示例:
<form method="get">
<input type="search" id="search" name="req" autocomplete="off" spellcheck="false" role="combobox"
placeholder="write here" aria-live="polite"><br>
<div class="form_radio_btn">
<input id="radio-1" type="radio" name="radio" value="first" checked>
<label for="radio-1">first</label>
</div>
<div class="form_radio_btn">
<input id="radio-2" type="radio" name="radio" value="Second">
<label for="radio-2">second</label>
</div>
</form>请建议
发布于 2022-07-26 11:58:19
<form method="get">
<input type="search" id="search" name="req" autocomplete="off" spellcheck="false" role="combobox"
placeholder="write here" aria-live="polite" value="<?php if(isset($_REQUEST['req'])){ echo $_REQUEST['req'];}?>"><br>
<div class="form_radio_btn">
<input id="radio-1" type="radio" name="radio" value="first" <?php if(isset($_REQUEST['radio']) && $_REQUEST['radio']=='first'){ echo 'checked';}?>>
<label for="radio-1">first</label>
</div>
<div class="form_radio_btn">
<input id="radio-2" type="radio" name="radio" value="Second" <?php if(isset($_REQUEST['radio']) && $_REQUEST['radio']=='Second'){ echo 'checked';}?>>
<label for="radio-2">second</label>
</div>
</form>或者使用Ajax
发布于 2022-07-26 11:52:12
调用event.preventDefault()并使用js发出http请求
https://stackoverflow.com/questions/73122834
复制相似问题