问题描述
我想显示链接中描述的列表。
只要选择下拉列表中的值,然后它应该立即保存这个值。
I want to display a list as described in the link. http://imgur.com/3zeSdAs soon as the value in dropdown is choosen. Then it should save the value immediately.
编辑: -
the code that i have written which is working...This is in loop.
<tr>
<td><?php $number += 1; echo $number;?></td>
<td><?php echo $record['db1_CON_NUMBER'];?></td>
<td><?php echo $record['DB1_status'];?></td>
<td width="100" class="rtodata">
<select name="action_db2" id=<?php echo $record['db1_CON_NUMBER']; ?> onchange="mark_doubleones_1('doubleones1.php?tab=doubleones&id='+this.id+'&value='+this.value);">
<option value=""<?php if( $action_db1 == '') echo 'SELECTED';?></option>
<option value="yes"<?php if( $action_db2 == 'yes') echo 'SELECTED';?>>Ok to Invoice</option>
<option value="no"<?php if( $action_db2 == 'no') echo 'SELECTED';?>>Exclude</option>
</select>
</td>
</tr>
和javascript
and in javascript
function mark_doubleones_1(url){
document.location.href = url;
}
现在@mistabell建议的另一种方法是,
Now the other method which @mistabell suggested,
<select name="action_db2" id=<?php echo $record['db1_CON_NUMBER']; ?> onchange="updateItem(this)">
并且故事在...
推荐答案
jQuery('.rtodata select').bind('change', function (e) {
jQuery.ajax({
type: 'post',
url: 'ajax-file.php',
data: {
value: jQuery('select option:selected', jQuery(e.currentTarget).parent()).val()
},
success: function (r) {
alert('success');
},
error: function (error, t, msg) {
alert('failed');
}
});
}
使用此方法, ajax-file.php
将会收到您的值通过 $ _ POST
。此方法不需要对HTML进行任何修改,并且效率更高,因为您不需要使用 onClick =。 ...
,从而减少必须下载才能查看页面的HTML数量。
With this method, ajax-file.php
will receive your value via $_POST
. This method does not require any modification to your HTML and is more efficient because you don't need to use onClick="...."
thus reducing the amount of HTML that must be downloaded to view the page.
这篇关于带编辑选项的逻辑4表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!