我有一份工作,现在在同一面板中申请,然后从数据库中获取工作详细信息。单击立即申请按钮时如何获得工作名称。
jobs.php
<div class="container clearfix">
<div class="col_three_fifth nobottommargin">
<?php
include('admin/config.php');
$host = "localhost";
$user = "root";
$pass = "";
$db_name = "demo";
$lastId="";
$con = mysqli_connect($host, $user, $pass, $db_name);
$sql = "SELECT * FROM job_update";
$result = mysqli_query($con,$sql);
if(mysqli_num_rows($result) > 0)
{
while($row = mysqli_fetch_assoc($result))
{
?>
<div class="panel panel-default">
<div class="panel-heading" role="tab" >
<h4 class="panel-title">
<a role="button" data-toggle="collapse" href="#<?php echo $row['id']?>" aria-expanded="true" class="trigger collapsed">
<?php echo $row['job_name'];?>
</a>
</h4>
</div>
<div id="<?php echo $row['id']?>" class="panel-collapse collapse" role="tabpanel" >
<div class="panel-body">
<ul class="iconlist iconlist-color nobottommargin" style="list-style-type: disc!important;">
<?php
// echo '<li>'.nl2br($row['job_description']).'</li>'
echo '<li>'.str_replace(array("\r","\n\n","\n"),array('',"\n","</li>\n<li>"),trim($row['job_description'],"\n\r")).'</li>';
?>
</ul>
<a href="#apply"><button id="<?php echo $row['id'];?>" class="btn btn-primary apply pull-right">Apply Now</button></a>
</div>
</div>
</div>
<?php
}
}
?>
</div>
</div>
单击立即申请按钮时,如何从面板上获取ID或名称。
先谢谢您!
答案 0 :(得分:1)
在您点击的按钮上方的html
内添加这两个标签。
<input type="hidden" id="job_id" value="<?php echo $row['id']?>">
<input type="hidden" id="job_name" value="<?php echo $row['job_name'];?>">
然后,当您单击按钮时,必须在j查询中调用click
函数。
$("button").click(function(){
alert($("#job_id").val()) //job_id would be your tag id where you put job id
alert($("#job_name").val()) //job_name would be your tag id where you put job name.
});
答案 1 :(得分:0)
如果您想要工作名称。因此,您必须使用点击功能jquery。
<input type="hidden" class="job" name="job_name" value="<?php echo $row['job_name'];?>">
<button id="submit">apply now</button>
<script>
$(document).ready(function(){
$("#submit").click(function(){
job_name = $(".job").val();
alert(job_name);
});
});
</script>