我试图在按下“运行脚本”按钮后创建一个确认()消息,但是如果填写了一个表单字段,我希望显示不同的消息。
这是我现在在表单上使用的代码,它可以正常工作,但不知道如何向它添加更多IF语句,因此如果填写了Form1.projectid.value,它会发生变化,如果没有填写则另一条消息。是否可能?
工作代码:
<form method="post" id="Form1" name="Form1">
<input type="hidden" name="Action" value="" />
<table style="table-layout: fixed; overflow: hidden; padding: 1px; border: none;">
<tr>
<td>Cut-Off Period:</td>
<td>
<select name="cutoff" class="TdInput" style="width: 180px">
<option value="<%=sPrevPrev%>"><%=sPrevPrev%></option>
<option value="<%=sPrev%>" selected><%=sPrev%> (Normally this!)</option>
<option value="<%=sThis%>"><%=sThis%></option>
</select>
</td>
</tr>
<tr>
<td nowrap>BA selection:
</td>
<td nowrap>
<select name="batype" id="demo" class="TdInput" style="width: 180px" onchange="this.form.submit()">
<option value="" <%if sBaType = "" then response.write(" selected ") end if%>>Choose BA from list</option>
<option value="BAN" <%if sBaType = "BAN" then response.write(" selected ") end if%>>BA Norway</option>
<option value="FS" <%if sBaType = "FS" then response.write(" selected ") end if%>>BA F. Services</option>
</select>
</td>
</tr>
<tr>
<td nowrap>People selection: </b>
<a href="javascript:void(0);">
<img src="images/eraser.png" width="16" height="16" border="0" title="Clear selection!" onclick="JavaScript:resetSelectElement(Form1.Selection);" />
</a>
<img src="images\Transparent.png" width="16" height="16" border="0" />
</td>
<td>
<select name="Selection" class="TdInput" style="width: 180px; height: 100px;" multiple>
<%
sSql=_
"select t.user_id, person_info_api.get_name(t.user_id) name "&_
"from EDB_BA_EXCEL_LIST_TAB t "&_
"where t.ba = '"&sBaType&"' "&_
"order by 2"
set rs=ConnOracle.Execute(sSql)
Do while not rs.eof%>
<option value="<%=rs("user_id")%>" <%if instr(sSelection,rs("user_id"))>0 then response.write(" selected ") end if%>><%=rs("name")%></option>
<%
rs.MoveNext
loop%>
</select>
</td>
</tr>
<tr>
<td>Additional selection:
</td>
<td>
<input type="text" name="empno" value="<%=sEmpNo%>" class="TdInput" maxlength="40" style="width: 180px;" />
<img style="cursor: pointer;" src="/PeoplePicker/Images/more4.png" border="0" width="13" height="13" title="Lookup employee..." onclick="javaScript: void (MainWindow =
window.open('/PeoplePicker/indexEmpNo.asp?FormName=Form1&FieldName=empno&AddReplace=R', 'PeoplePicker', 'resizable=yes, scrollbars=yes, width=580, height=300'))" />
</td>
</tr>
<tr>
<td nowrap>Project ID:
</td>
<td nowrap>
<input type="text" class="tdinput" size="10" maxlength="10" name="projectid" value="<%=sProjectID%>" style="width: 180px">
</td>
</tr>
<tr>
<td nowrap>Show output on:
</td>
<td nowrap>
<select name="output" class="TdInput" style="width: 180px">
<option value="" <%if sOutput = "" then response.write(" selected ") end if%>>Select from list</option>
<option value="Email" <%if sOutput = "Email" then response.write(" selected ") end if%>>Email</option>
<option value="Screen" <%if sOutput = "Screen" then response.write(" selected ") end if%>>Screen</option>
<option value="Both" <%if sOutput = "Both" then response.write(" selected ") end if%>>Both</option>
</select>
</td>
</tr>
<tr>
<td> </td>
<td>
<input type="submit" class="button" value="Run Script..." onclick="if ( confirm('Confirm that you want to create report for <%=request("batype")%>, ' + Form1.projectid.value + '!')) {Form1.Action.value = 'Save';}" />
<input type="submit" value="Search..." name="send" class="button" onclick="Form1.Action.value = 'Search'" />
</td>
</tr>
</table>
</form>
这是我尝试创建以完成它但当前无法正常工作的代码..:
<script>
function myFunction() {
msg = " ";
console.log(Form1.projectid.value);
if ( Form1.projectid.value =! null)
{
msg = "Confirm that you want to create report for " + Form1.batype.value + " , " + Form1.projectid.value + "!";
confirm(msg)
}
else
{
msg = "Confirm that you want to create report for the project " + Form1.projectid.value + "!";
confirm(msg)
}
document.getElementById("demo").innerHTML = txt;
}
</script>
对此有何帮助?