この JavaScript をしばらく実行していましたが、少し変更したため、実行すらできなくなりました。しばらく JavaScript でアラートが発生しましたが、それをトリガーすることさえできませんでした。このコードの上に PHP がいくつかありますが、JavaScript に干渉するべきではありません。
<form action="http://go.gbpi.net/Outage/add-question/" method="post">
Question Name (A descriptive name for the question. Example: "Phone number", or "Pizza Size"): <br /><input type="text" name="questionName" />
<?php
echo("Category: <br /><select name=\"category\" id=\"category\">");
$mysqli = db_init();
$mysqli->next_result();
$cats = $mysqli->query("call GetActiveCategories()");
while ($row = $cats->fetch_assoc()){
$categori = $row['Category_Text'];
if(!($categori == $category)){
echo("<option value = \"".$categori."\">".$categori."</option>");}
}
echo("</select>");
?>
Question Text:<br /><input type="text" name="questionText" style='width:80%' />
Question Type:<br /><select name="myList" id="myList" onchange="selectType(); return false;">
<option value = "1">Yes or No</option>
<option value = "2">Multiple Choice</option>
<option value = "3">Multiple Select</option>
<option value = "4">Open Response</option>
<option value = "5">Final Reply</option>
<option value = "6">Summary</option>
</select>
<div id='regexes'>
type of input: <br /><select name="regex" id="regex">
<option value = "-1">any input</option>
<?php
$mysqli->next_result();
$regexes = $mysqli->query("call GetValidRegexes()");
while($regex_row = $regexes->fetch_assoc()){
$rid = $regex_row['Validation_ID'];
$rname = $regex_row['Validation_Name'];
echo("<option value = \"".$rid."\">".$rname."</option>");
}
?>
</select>
</div>
<div id='buttons'></div>
<button id="adda" onclick="addAnswer(); return false;">add answer (max: 10)</button>
<input type="submit" value="add question" />
</form>
<?php
echo("<a href='./define-relationships/'>Define Question Relationships</a><br />");
?>
<script type="text/javascript">
document.getElementById("adda").style.visibility="hidden";
</script>
<script type="text/javascript">
var answers = 0;
var inHTML = "";
function addAnswer()
{
if(answers < 10){
write = document.getElementById('buttons');
write.innerHTML = write.innerHTML + "answer: <input type=\"text\" name=\"answer" + answers + "\" /> <br>";
answers = answers + 1;}
}
</script>
<script type="text/javascript">
function selectType()
{
alert("HAHA I HATE YOU!");
var type=document.getElementById("myList").value;
if(type == "2" || type == "3"){
document.getElementById("buttons").style.visibility="visible";
document.getElementById("adda").style.visibility="visible";
document.getElementById("regexes").style.visibility="hidden";
}
else if(type == "4"{
document.getElementById("buttons").style.visibility="hidden";
document.getElementById("adda").style.visibility="hidden";
document.getElementById("regexes").style.visibility="visible";
}
else{
document.getElementById("buttons").style.visibility="hidden";
document.getElementById("adda").style.visibility="hidden";
document.getElementById("regexes").style.visibility="hidden";
}}
</script>