当我单击搜索图标时,它会提醒def tree_height(node):
parent, children = node
return max([tree_height(child) + 1 for child in children]) if children else 0
,但不会提醒ok
。
根据下面的代码,它应该同时提醒h
和ok
。
h
<?php if(isset($_POST['search'])){
echo "<script type='text/javascript'>alert('h');</script>";
} ?>
<form method="post">
<div class="col_1">
<select name="search_type" required="">
<option value="0">Anywhere</option>
<option value="1">Start With</option>
<option value="2">End With</option>
</select>
</div>
<div class="col_2">
<input type="number" name="search_q" data-type="num" maxlength="10" placeholder="Digit" required="">
</div>
<div class="col_3">
<input type="submit" name="search" id="input_submit" hidden />
<button type="submit" id="button_submit"><i class="fa fa-search"></i></button>
</div>
</form>
答案 0 :(得分:0)
您没有在请求中发送search
值。
<input name="search" />
被隐藏(因此不会被单击),即使它可见也没有value
可以发送请求。
要解决此问题,请删除input
,然后将name
和value
属性放在<button>
上:
<?php if(isset($_POST['search']))
{
echo "<script type='text/javascript'>console.log('h');</script>";
} ?>
<form method="post">
<div class="col_1">
<select name="search_type" required="">
<option value="0">Anywhere</option>
<option value="1">Start With</option>
<option value="2">End With</option>
</select>
</div>
<div class="col_2">
<input type="number" name="search_q" data-type="num" maxlength="10" placeholder="Digit" required="">
</div>
<div class="col_3">
<button type="submit" id="button_submit" name="search" value="foobar">
<i class="fa fa-search"></i>
</button>
</div>
</form>
$('#button_submit').click(function() {
$('#input_submit').click();
console.log("ok");
});