我有一个下拉菜单,其中包含一些类别,每个类别都有自己的子类别,我想向他们展示购买选择类别名称 但它不起作用,我是否错过了某些东西,或者我完全错了?
Sub CopyValue()
Dim wbFrom As Workbook, wbto As Workbook
Dim wsFrom As Worksheet, wsTo As Worksheet
Set wbFrom = Workbooks(fromimportfilename)
Set wbto = Workbooks(toimportfilename)
Set wsFrom = wbFrom.Sheets("Sheet1")
Set wsTo = wbto.Sheets("Sheet1")
'to copy all cells, visible and Hidden
wsTo.Range("E9:E200").Value = wbFrom.Range("F9:F200").Value
'to copy only the visible cells
Set rngVisible = wbFrom.Range("F9:F200").SpecialCells(xlCellTypeVisible)
rngVisible.Copy Destination:=wsTo.Range("F9") 'I use F colum to show u the difference from the two paste method
End Sub
答案 0 :(得分:0)
试试这个,
if table is not empty
do something
else
do something else
end if
在$.ajax({
type:"POST",
url:"get_subcategory.php",
data:data,
success: function(data){
alert(data)// this will have the second dropdown. add to desired place in your view.
}
});
get_subcategory.php
答案 1 :(得分:0)
<强> SomePage.php 强>
<form id="form" name="form">
<div id='category'>
<label for="category" id="error">Empty</label>
<select name="category" id="category">
<option></option>
<option value="News">News</option>
<option value="Items">Items</option>
<option value="Updates">Updates</option>
</select>
</div>
<div id='subcategory'>
</div>
</form>
<script>
$('#category').change(function(){
var CatName= $('#category').val();
$.ajax({url:"AjaxSelectCategory.php?CatName="+CatName,cache:false,success:function(result){
$('#subcategory').html(result);
}});
});
</script>
创建新页 AjaxSelectCategory.php
[注意:如果要更改此页面名称。也可以更改<script></script>
标记。两者都是相关的。]
<?php
include("connect.php");
if(!empty($_GET['CatName']))
{
$sql=$con->prepare("SELECT * FROM categorys WHERE category=:category ");
$sql->bindparam(":category",$_GET['CatName']);
$sql->execute();
?>
<select name='subcategory'>
<?php
while($r=$sql->fetch())
{?>
<option value="<?php echo $r['subcategory'];?>"><?php echo $r['subcategory'];?></option>
</select>
<?php }
}?>