Hvis felter er tomme, skal VBScript skrive tekst i <span>
Jeg kan ikke få mit VBScript til at indsætte tekst i et <span></span> hvis et par felter er tomme.Jeg får denne fejlmeddelse på linje 7:
"Objektet understøtter ikke denne egenskab eller metode: 'Error.InnerHTML'"
Hvad er problemet?
KILDEKODE:
--------------------------------------------------------------
<script language="vbscript">
sub save_onclick()
if post_data.phone_code.value = "" or post_data.phone.value = "" or post_data.mobile_code.value = "" or post_data.mobile.value = "" then
Error.InnerHTML = errortext
else
post_data.jobtitle_ml.value = replace(post_data.jobtitle.value,"'","")
post_data.jobtitle_ml.value = replace(post_data.jobtitle_ml.value,"chr(34)","")
post_data.fname_ml.value = replace(post_data.fname.value,"'","")
post_data.fname_ml.value = replace(post_data.fname_ml.value,"chr(34)","")
post_data.lname_ml.value = replace(post_data.lname.value,"'","")
post_data.lname_ml.value = replace(post_data.lname_ml.value,"chr(34)","")
post_data.phone_code_ml.value = replace(post_data.phone_code.value,"'","")
post_data.phone_code_ml.value = replace(post_data.phone_code_ml.value,"chr(34)","")
post_data.phone_ml.value = replace(post_data.phone.value,"'","")
post_data.phone_ml.value = replace(post_data.phone_ml.value,"chr(34)","")
post_data.mobile_code_ml.value = replace(post_data.mobile_code.value,"'","")
post_data.mobile_code_ml.value = replace(post_data.mobile_code_ml.value,"chr(34)","")
post_data.mobile_ml.value = replace(post_data.mobile.value,"'","")
post_data.mobile_ml.value = replace(post_data.mobile_ml.value,"chr(34)","")
post_data.email_ml.value = replace(post_data.email.value,"'","")
post_data.email_ml.value = replace(post_data.email_ml.value,"chr(34)","")
post_data.submit
end if
end sub
</script>
<%
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ="& Server.MapPath("../mdb/data.gif") &";UID=;PWD=*************"
if Request.Querystring("usr") <> "" then
Set rs = Conn.execute("SELECT username, jobtitle, fname, lname, phone_code, phone, mobile_code, mobile, email FROM users WHERE username='"& Request.Querystring("usr") &"'")
if (rs.BOF or rs.EOF) then
Response.Write "No data was found."
else
end if
usernameVar = rs("username")
else %>
<body onLoad="window.close()">
</body>
<% end if
%>
<form method="POST" name="post_data" id="post_data" action="update.asp?usr=<%=usernameVar%>">
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%">
<tr>
<td width="50%" valign="top">
<b>Jobtitle:<br><input type="text" name="jobtitle" id="jobtitle" value="<%=rs("jobtitle")%>" size="30"><p>
Firstname:<br><input type="text" name="fname" id="fname" value="<%=rs("fname")%>" size="30"><br>
Lastname:<br><input type="text" name="lname" id="lname" value="<%=rs("lname")%>" size="30"></b></td>
<td width="50%" valign="top">
<b>Phone:<br>+<input type="text" name="phone_code" id="phone_code" value="<%=rs("phone_code")%>" size="2" value="45"><input type="text" name="phone" id="phone" value="<%=rs("phone")%>" size="20"><br>
Mobile:<br>+<input type="text" name="mobile_code" id="mobile_code" value="<%=rs("mobile_code")%>" size="2" value="45"><input type="text" name="mobile" id="mobile" value="<%=rs("mobile")%>" size="20"><p>
Email adress:<br>
<input type="text" name="email" id="email" value="<%=rs("email")%>" size="28"></b></td>
</tr>
</table>
<input type="hidden" name="jobtitle_ml" id="jobtitle_ml" value="">
<input type="hidden" name="fname_ml" id="fname_ml" value="">
<input type="hidden" name="lname_ml" id="lname_ml" value="">
<input type="hidden" name="phone_code_ml" id="phone_code_ml" value="">
<input type="hidden" name="phone_ml" id="phone_ml" value="">
<input type="hidden" name="mobile_code_ml" id="mobile_code_ml" value="">
<input type="hidden" name="mobile_ml" id="mobile_ml" value="">
<input type="hidden" name="email_ml" id="email_ml" value="">
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%">
<tr>
<td width="50%"><input type="button" value="Save" name="save" id="save"><input type="reset" value="Reset" name="reset" id="reset"><input type="button" onclick="java script:window.close()" value="Close" name="close" id="close"></td>
<td width="50%"><font color="FF0000"><b><span id="Error"></span></b></font></td>
</tr>
</table>
</form>