我正在创建python项目,我在其中创建了下拉字段模型.py,然后我必须在html模板中显示。我已经编写了jquery代码还有,但是力量工作。在
模型.py
addtype = models.CharField(max_length=25,choices=STATE_CHOICES,default='seller')
表单.py
^{pr2}$视图.py
^{3}$广告.html
<head>
<script src="../static/js/jquery-1.9.1.js"></script>
<script type="text/javascript">
alert("111");
$('#adtype').on('change', function() {
alert("aa");
var lb = $('#adtype').val();
if(lb = "seller")
{
aler("1");
$('#seller').hide();
$('#buyer').show();
}
else
{
$('#buyer').hide();
$('#seller').show();
}
});
</script>
</head>
<p>
{{ product_form.addtype.errors }}
<label>Type of Ad:</label>
<select name="ad"id="adtype">
<option value="seller">Seller</option>
<option value="buyer">Buyer</option>
</select>
</p>
<label id="seller"> Seller Information</label>
<label id="buyer" style="display: none;"> Buyer Information</label>
上面的标签要更改。如果我单击卖家,我想将标签更改为卖家信息,反之亦然
赋值将始终被评估为true:
试试看
^{pr2}$相关问题 更多 >
编程相关推荐