Php 更新组合值
我有一个简单显示一些mysql数据库的组合。我还有一个创建数据库的表单。我想动态刷新组合(如果可能的话),以显示由表单创建的新数据库。以下是代码片段:Php 更新组合值,php,jquery,html,Php,Jquery,Html,我有一个简单显示一些mysql数据库的组合。我还有一个创建数据库的表单。我想动态刷新组合(如果可能的话),以显示由表单创建的新数据库。以下是代码片段: <div id="tools"> <P>Add a Set list:<br> <LABEL for="labelName">Set List Name: </LABEL> <INPUT type="text" name="sl
<div id="tools">
<P>Add a Set list:<br>
<LABEL for="labelName">Set List Name: </LABEL>
<INPUT type="text" name="slName" id="slName"><button id="createSL" value="Create Setlist">Create Set</button>
</P><br>
<P>Delete a Set list:<br>
<? include("remSLcombo.php"); ?> <button href="#" type="button" id="delSl">Delete Setlist</button>
</P>
<p>Check how to reload combos</p>
</div><BR>
<? include("combo.php"); ?>
Combo.php:
<?php
echo '<select id="tunelist" name="tunelist" >';
$link = mysql_connect('localhost', 'setlist', 'music');
$query = mysql_query("SHOW DATABASES");
echo '<option>Select a Show</option>';
while ($row = mysql_fetch_assoc($query)) {
if ($row['Database'] == "information_schema"){}
elseif ($row['Database'] == "performance_schema"){}
elseif ($row['Database'] == "mysql"){}
else{
echo '<option value="'.$row['Database'].'">'.$row['Database'].'</option>';
}
}
echo '</Select>';
?>
您需要做的是在createSL.php
中返回新组合框的代码并加载到那里
这是你的密码
success: function(response){
alert(response);
}
写一些类似于:
success: function(response){
$('#tunelist').html(response);
}
如果响应类似于Combo.php
请尝试移动
$(“#selcombo”).load(“combo.php”);
要在您的success
功能内部:
成功:功能(响应){
警报(响应);
if(response==true)//或类似的内容来确保操作的成功
$(“#selcombo”).load(“combo.php”);
}
@Sam我刚刚编辑了这个问题。抱歉弄糊涂了,我试过了。它似乎有影响,但实际上没有重新运行combo.php,因为没有显示新的数据库。
success: function(response){
$('#tunelist').html(response);
}