【发布时间】:2016-12-13 08:35:53
【问题描述】:
你好朋友,我的代码有问题, 在这段代码中,我希望当我按下保存按钮然后“Hello PHP”打印和名字的标签颜色改变但它不起作用,当我将提交输入按钮类型时,它显示“Hello PHP”并且标签颜色没有改变,当我按钮类型中的按钮然后标签颜色更改但不打印'hello PHP',我想要保存按钮单击,请帮助我摆脱这段代码
这是我的代码:
<?php
//php code
$isSaveDisabled=true;
$isCreateDisabled=false;
if(isset($_POST['save_button']))
{
echo 'Hello PHP';
}
if(isset($_POST['create_button']))
{
$isSaveDisabled=false;
}
?>
// BootStrap Code
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>My New PHP CODE</title>
<link rel="stylesheet" href="bootStrap/css/bootstrap.css"/>
<link rel="stylesheet" href="bootStrap/css/bootstrap.min.css"/>
<script type="text/javascript">
function myFunction() {
document.getElementById("myID").style.color = "#ff0000";
}
</script>
</head>
<body>
<div class="container jumbotron text-center">
<form action="" method="POST" class="form-inline">
<div class="form-group">
<label for="fname" id="myID">FIRST NAME</label>
<input type="text" name="fname" class="form-control" >
<label for="nlame">LAST NAME</label>
<input type="text" name="lname" class="form-control" >
</div>
<br><br>
<div class="btn-group">
<button type="submit" name="save_button" onclick="myFunction();" <?php echo $isSaveDisabled? 'disabled':'';?>>SAVE</button>
<button type="submit" name="create_button" <?php echo $isCreateDisabled? 'disabled':''?> >CREATE</button>
</div>
</form>
</div>
</body>
</html>
【问题讨论】:
标签: jquery html twitter-bootstrap