我想知道是否有人可以帮助解决以下简单的代码:
PROJECT(project_name)
SET(SRC_FILES xxx.c xxx.c xxx.c xxx.c)
FIND_PACKAGE(SDL2 REQUIRED)
INCLUDE_DIRECTORIES(${SDL2_INCLUDE_DIR})
FIND_PACKAGE(OPENGL REQUIRED)
INCLUDE_DIRECTORIES( ${OPENGL_INCLUDE_DIR})
FIND_PACKAGE(SDL_IMAGE REQUIRED)
INCLUDE_DIRECTORIES( ${SDL2_IMAGE_INCLUDE_DIR})
ADD_LIBRARY(project_name SHARED ${SRC_FILES})
TARGET_LINK_LIBRARIES(project_name ${SDL2_LIBRARY} ${OPENGL_LIBRARIES} ${SDL2_IMAGE_LIBRARY})
我基本上试图复制if语句,根据IF语句的真实与否,给出3种不同的结果。
答案 0 :(得分:2)
试试这个;
<html>
<head>
<title>Exam entry</title>
<script language="javascript" type="text/javascript">
var number = true;
var validNumbers = "0123456789";
var character;
function validateForm() {
var result = true;
var msg="";
if (document.ExamEntry.name.value=="") {
msg+="You must enter your name \n";
document.ExamEntry.name.focus();
document.getElementById('name').style.color="red";
result = false;
}
if (document.ExamEntry.subject.value=="") {
msg+="You must enter the subject \n";
document.ExamEntry.subject.focus();
document.getElementById('subject').style.color="red";
result = false;
}
number = true
for(var i = 0;i<document.ExamEntry.examNumber.value.length;i++){
character = document.ExamEntry.examNumber.value.charAt(i);
if (validNumbers.indexOf(character) == -1){
number = false;
}
}
if (document.ExamEntry.examNumber.value.length != 4||number==false){
msg+="You must enter your examination number correctly \n";
document.ExamEntry.examNumber.focus();
document.getElementById('examNumber').style.color="red";
result = false;
}
if(msg==""){
return result;
}
{
alert(msg)
return result;
}
}
</script>
</head>
<body>
<h1>Exam Entry Form</h1>
<form name="ExamEntry" method="post" action="success.html">
<table width="50%" border="0">
<tr>
<td id="name">Name</td>
<td><input type="text" name="name" /></td>
</tr>
<tr>
<td id="subject">Subject</td>
<td><input type="text" name="subject" /></td>
</tr>
<tr>
<td id="examNumber">Examination Number</td>
<td><input type="text" name="examNumber" /></td>
</tr>
<tr>
<td><input type="submit" name="Submit" value="Submit" onclick="return validateForm();" /></td>
<td><input type="reset" name="Reset" value="Reset" /></td>
</tr>
</table>
</form>
</body>
</html>
答案 1 :(得分:1)