自定义数据属性,剪切并嵌入<img>
Custom data attributes, chopped and embed a <img>
我在mysql 中有这个
<select>
<?php echo "<option value='"'">Select Person:</option>";?>
<?php while ($row=mysqli_fetch_array($result, MYSQL_ASSOC)) {
echo "<option value='{$row['idvisa']}' data-visanumber='{$row['visanumber']}' data-idnumber='{$row['idnumber']}' data-statusapp='{$row['statusapp']}' data-accntVisaPhotoPath='{$row['accntVisaPhotoPath']}' data-passport='{$row['passportPath]}' data-subdate='{$row['subdate']}'>".$row['fName']." ".$row['lName']."</option>";
}
?>
</select>
但后来有什么东西被砍了。它显示为"For",但当我选中它时,它应该是"For Select"。。
脚本:
<script>
$(function(){
$('select').change(function(){
var selected = $(this).find('option:selected');
var $parent = $(this).parents("tr");
$parent.find('#visanumber').html(selected.data('visanumber'));
$parent.find('#idnumber').html(selected.data('idnumber'));
$parent.find('#statusapp').html(selected.data('statusapp'));
$parent.find('#accntVisaPhotoPath').html(selected.data('ImageUrl').accntVisaPhotoPath); //for testing
$parent.find('#passportPath').html(selected.data('passportPath'));
});
});
</script>
我的脚本提供了动态的下拉菜单,但不知道为什么它会被砍掉。第二,如何在自定义数据属性中嵌入标记?
我的L A B。。。已经快一周了,请帮忙。我把头发连根拔起,现在几乎没了。。lol
因为您忘记了引号!查看生成的源代码:
<option value=1 data-visanumber=1234567890 data-idnumber=0987654321 data-statusapp=For Selection data-accntVisaPhotoPath= data-passport= data-subdate=2014-09-21 02:13:50>
应该是
<option value="1" data-visanumber="1234567890" data-idnumber="0987654321" data-statusapp="For Selection" data-accntVisaPhotoPath="" data-passport="" data-subdate="2014-09-21 02:13:50">
相关文章:
- 如何更改<svg>标记为<img>用js标记
- 图像可以从源<img src=""/>.TEXT可以在没有javascript的情况下从外部
- 检索MongoDB binData并显示为<img>src
- AngularJS提取物<img>来自JSON
- 隐藏<img>在移动设备上
- 如何从<img>标记
- HTML5我可以使用<img>其中<来源>
- 做<img>或者<画布>保存对原始(大)dataUrl对象的引用
- 设置& lt; img>用Javascript转换base64编码的图像失败
- 使用& lt; img>图像作为另一个元素的背景
- jQuery -目标.href & lt; a href =“#“祝辞& lt; img> & lt; / a>
- HTML & lt; img>(或JS图像)与通过PHP内联图像(base64_encoded图像)
- 数& lt; img>在
没有id或类
- 禁用& lt; img>在ie9中选择和调整可内容DIV的大小
- 奇怪的& lt; img>位置的行为
- 找到& lt; img>标记在文本字符串内
- 重载& lt; img>元素来自同一来源
- onerror & lt; img>标签属性总是在IE中触发,为什么?
- 解析& lt; img>SRC属性在