如何在jquery中获得价值? [英] How to get value in jquery?
问题描述
Hi, 这篇关于如何在jquery中获得价值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
我有一个表单,我正在获取价值表格数据库。
现在我添加一个删除按钮,并想添加一个删除它的功能使用jquery代码。
但无法做到这一点。
它只显示第一个值。
< pre lang =PHP> <?php
$ i = 0;
$ total_amount = 0;
while ($ i< $ num)
{
$ f0 = mysql_result($ query_for_result,$ i, empta_id);
$ f1 = mysql_result($ query_for_result,$ i, department);
$ f2 = mysql_result($ query_for_result,$ i, username);
$ f3 = mysql_result($ query_for_result,$ i, amount);
?>
< tr valign = top >
<! - < td style =border-removed#cdcdcd solid; border-bottom-width:1px;><?php echo $ f0; ?>< / td> - >
< td style = border-removed#cdcdcd solid; border-bottom-width:1px; > <? php echo $ F1 跨度>; ?> < / td < span class =code-keyword>>
< td style = border-removed#cdcdcd solid; border-bottom-width:1px; > <? php echo $ f2 ; ?> < / td < span class =code-keyword>>
< td style = border-removed#cdcdcd solid; border-bottom-width:1px; > <? php echo $ f3 ; ?> < / td < span class =code-keyword>>
<! - < td style =border-removed#cdcdcd solid; border-bottom-width:1px;>< a href =delete-ta-info.php?empta_id =< ?php echo $ f0;?>>删除< / a>< / td> - >
< td 样式 = border-removed#cdcdcd solid; border-bottom-width :1px; > < a href = id = del 名称 = del önclick = delete_ta(); > 删除< / a > < / td >
< td style = border-removed#cdcdcd solid; border-bottom-width:1px; > < 输入 type = 隐藏 < span class =code-attribute> id = empta 名称 = empta value = <?php echo $ i; ?> / > < ; / div > < / td > < / tr >
<? php
$ i ++;
}
?> < / table >
< script >
function delete_ta()
{
var empta_id = $(' #EMPTA'跨度>)VAL();
alert(empta_id);
}
< / script >
有谁有任何想法?我哪里错了?如果我应该在这里使用索引,那么请用代码示例帮助我。
现在我能够获得这样的索引值......
< td 样式 = border-已删除#cdcdcd solid; border-bottom-width:1px; > < input 类型 = 隐藏 id = empta<?php echo $ i;?> name = empta<?php echo $ i;?> value = <?php echo $ i; ?> / > < ; / td >
现在唯一的问题是如何在jquery函数中访问这个值。
谢谢 i = 0;
total_amount = 0;
while (
i<
I have a form in which i am getting value form database.
Now i add a delete button and want to add a function by which it delete using jquery code.
But unable to do this.
It only showing the first value.
<?php
$i=0;
$total_amount=0;
while ($i < $num)
{
$f0=mysql_result($query_for_result,$i,"empta_id");
$f1=mysql_result($query_for_result,$i,"department");
$f2=mysql_result($query_for_result,$i,"username");
$f3=mysql_result($query_for_result,$i,"amount");
?>
<tr valign="top" >
<!--<td style="border-removed#cdcdcd solid; border-bottom-width:1px;"><?php echo $f0; ?></td>-->
<td style="border-removed#cdcdcd solid; border-bottom-width:1px;"><?php echo $f1; ?></td>
<td style="border-removed#cdcdcd solid; border-bottom-width:1px;"><?php echo $f2; ?></td>
<td style="border-removed#cdcdcd solid; border-bottom-width:1px;"><?php echo $f3; ?></td>
<!--<td style="border-removed#cdcdcd solid; border-bottom-width:1px;"><a href="delete-ta-info.php?empta_id=<?php echo $f0; ?>">Delete</a></td>-->
<td style="border-removed#cdcdcd solid; border-bottom-width:1px;"><a href="" id="del" name="del" önclick="delete_ta();">Delete</a></td>
<td style="border-removed#cdcdcd solid; border-bottom-width:1px;" ><input type="hidden" id="empta" name="empta" value="<?php echo $i; ?>"/></div></td></tr>
<?php
$i++;
}
?></table>
<script>
function delete_ta()
{
var empta_id=$('#empta').val();
alert(empta_id);
}
</script>
Can anybody have any idea? where i am going wrong? and if i should use indexing here then please help me with example with code.
Now I am able to get the index value like this...
<td style="border-removed#cdcdcd solid; border-bottom-width:1px;" ><input type="hidden" id="empta<?php echo $i;?>" name="empta<?php echo $i;?>" value="<?php echo $i; ?>"/></td>
Now only problem is how to access this value in jquery function.
thanksi=0;
total_amount=0;
while (
i <