Bertrendy
asked on
Onfocus errors
I am having an issue where when I click on the text box the original text dissapears, and if I click off the textarea and then back to it, all the text dispears. This is on a form that needs to be sumbmitted, so the text needs to display. I tried looking up similar questions, but none of the other accepted solutions worked.
<textarea cols="70%" rows="5" name="step<% Response.Write(i) %>txt" id="step<% Response.Write(i) %>txt" style="display: none;" onfocus='this.value="";'>N OTES:</tex tarea>
<textarea cols="70%" rows="5" name="step<% Response.Write(i) %>txt" id="step<% Response.Write(i) %>txt" style="display: none;" onfocus='this.value="";'>N
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Show us what have you done till now
ASKER
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- #include virtual="/masterincludes/i ntranet-fu nctions.in c" -->
<html>
<head>
<title>
Technical Support
</title>
<!-- #include virtual="/masterincludes/c ss-js.inc" -->
<script language="JavaScript">
function checkForm() {
var b = document.getElementsByTagN ame('selec t');
for (i = 0; i < b.length ; i++) {
if (eval("document.myForm.que stion" + i + ".value") == "NOT TESTED") {
alert("Please COMPLETE step #" + (i + 1) + " to submit.");
eval("document.myForm.ques tion" + i + ".focus()");
return false;
}
}
document.myForm.submit();
}
function openCalendarWindow(formVar ) {
newWin = window.open("/calendar-pop up.asp?for mVar=" + formVar,"cal","dependent=y es,width=2 10,height= 210,screen X=200,scre enY=300,ti tlebar=yes ");
}
function openWinSmall(pagename) {
smallWin2=open(pagename,"s mallwin2", "width=500 ,height=50 0,location =no,menuba r=no,resiz able=yes,s crollbars= yes,status =no,toolba r=no");
}
function displayMessage(sel,div) {
var displayArea = document.getElementById('d isplay');
if (displayArea) {
if (sel.selectedIndex == 2) {
document.getElementById(di v).style.d isplay = 'block';
}
else if (sel.selectedIndex == 0) {
document.getElementById(di v).style.d isplay = 'none';
} else {
//We have to loop
var i = 0;
var selField;
while (selField = document.getElementById('s elect' + i)) {
if (selField.selectedIndex == 1) {
return;
}
}
document.getElementById(di v).style.d isplay = 'none';
}
}
}
</script>
</head>
<body>
<%
checkTitle="Checklist"
Dim step(13)
step(0) = "Confirm incident"
step(1) = "Confirm product."
step(2) = "Confirm has been installed"
step(3) = "Confirm the Environment"
step(4) = "Confirm is they have selected Test Mode that user ids have been provided."
step(5) = "Confirm that a test account has been provided."
step(6) = "Confirm that the test account can be logged into successfully
step(7) = "Confirm that the vendor has sent a confirmation email "
step(8) = "Confirm Form is attached."
step(9) = "Confirm Form is complete."
step(10) = "Confirm client form is attached."
step(11) = "Confirm client form is complete."
step(12) = "Confirm the location of the button."
step(13) = "Confirm that a button color has been selected." &_
%>
<span class="normalLgBox" style="margin: 10px;">
<div class="ms-WPHeader ms-WPTitle">
</div>
<div class="normalLgBoxContent" style="border-color: #000000;">
<center>
<strong><span class="largeText"><% Response.Write(checkTitle) %></span></strong>
<p>
<form method="post" name="myForm">
<table width="80%" cellspacing="" celpadding="5" align="center">
<% if request.form("status") <> "" then %>
<tr>
<td class="Strong" valign="top">Results:</td>
<td class="Strong" valign="top">
<%
dim a
dim passOrFail
passOrFail = "<font size=""+1"" color=""green"">PASS</font >"
for a = 0 to ubound(step)
if request.form("status") <> "" then
if request.form("question" & (a)) = "FAIL" then
passOrFail = "<font size=""+1"" color=""red"">FAIL</font>"
end if
end if
Next
Response.Write(passOrFail)
%>
</td>
</tr>
<tr>
<td class="Strong" valign="top">Date:</td>
<td class="normal" valign="top">
<script type="text/javascript">
var d=new Date()
//var weekday=new Array("Sunday","Monday","T uesday","W ednesday", "Thursday" ,"Friday", "Saturday" )
var monthname=new Array("01","02","03","04", "05","06", "07","08", "09","10", "11","12")
//document.write(weekday[d .getUTCDay ()] + ", ")
document.write(monthname[d .getUTCMon th()] + "/")
document.write(d.getUTCDat e() + "/")
document.write(d.getFullYe ar() + " ")
document.write(d.getHours( ) + ":" + d.getMinutes() + ":" + d.getSeconds())
</script>
</td>
</tr>
<tr>
<td class="Strong" valign="top">Tested By:</td>
<td class="normal" valign="top"><%= request.form("submitter") %></td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<% end if %>
<tr>
<td colspan="2"><div id="display"></div></td>
</tr>
<tr>
<td class="ms-WPHeader ms-WPTitle">PASS / FAIL</td>
<td class="ms-WPHeader ms-WPTitle" width="80%">Step</td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<%
dim i
for i = 0 to ubound(step)
if request.form("status") <> "" then
%>
<tr>
<td valign="top" class="strong">
<!-- RESULTS GO HERE (red if FAIL or INCOMPLETE) -->
<% if request.form("question" & (i)) = "FAIL" then %>
<font color="Red"><%= request.form("question" & (i)) %></font>
<% end if
if request.form("question" & (i)) = "N/A" then %>
<font color="#FF8800"><%= request.form("question" & (i)) %></font>
<% end if
if request.form("question" & (i)) = "PASS" then %>
<font color="Green"><%= request.form("question" & (i)) %></font>
<% end if %>
</td>
<td class="normal">
STEP: <% Response.Write(step(i)) %>
<!-- NOTES GO HERE IF ENTERED -->
<% if request.form("question" & (i)) = "FAIL" and request.form("step" & (i) & "txt") <> "NOTES:" and request.form("step" & (i) & "txt") <> "" then %>
<br><br>
<b>NOTES:</b> <%= request.form("step" & (i) & "txt") %>
<% end if %>
</td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<% else %>
<tr>
<td valign="top" class="strong">
<select name="question<% Response.Write(i) %>" onChange="displayMessage(t his, 'step<% Response.Write(i) %>txt')">
<option value="NOT TESTED"></option>
<option value="PASS">PASS</option>
<option value="FAIL">FAIL</option>
<option value="N/A">N/A</option>
</select></td>
<td class="normal">
<% Response.Write(step(i)) %><br><br>
<textarea cols="70%" rows="5" name="step<% Response.Write(i) %>txt" id="step<% Response.Write(i) %>txt" style="display: none;" onfocus='if (this.value=="NOTES:") this.value="";'>NOTES:</te xtarea>
</td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<%
end if
Next
%>
</table>
<input type="hidden" name="status" value="submitted">
<%
if request.form("status") <> "submitted" then
%>
<p>
<b>Submitted By:</b> <input type="text" name="submitter" value="<%= getCookie("nfront-intranet ","name") %>" size="40">
<input type="button" value="Submit" class="button" style="background-color: <%= Application("color2") %>; color: #ffffff; font-weight: bold;" onMouseOver="change('<%= Application("color1") %>');" onMouseOut="change('<%= Application("color2") %>');" onClick="checkForm();">
<% else %>
<input type="button" value="BACK" class="button" style="background-color: <%= Application("color2") %>; color: #ffffff; font-weight: bold;" onMouseOver="change('<%= Application("color1") %>');" onMouseOut="change('<%= Application("color2") %>');" onClick="javascript:histor y.back();" >
<% end if %>
</form>
</center>
<!-- #include virtual="/masterincludes/i
<html>
<head>
<title>
Technical Support
</title>
<!-- #include virtual="/masterincludes/c
<script language="JavaScript">
function checkForm() {
var b = document.getElementsByTagN
for (i = 0; i < b.length ; i++) {
if (eval("document.myForm.que
alert("Please COMPLETE step #" + (i + 1) + " to submit.");
eval("document.myForm.ques
return false;
}
}
document.myForm.submit();
}
function openCalendarWindow(formVar
newWin = window.open("/calendar-pop
}
function openWinSmall(pagename) {
smallWin2=open(pagename,"s
}
function displayMessage(sel,div) {
var displayArea = document.getElementById('d
if (displayArea) {
if (sel.selectedIndex == 2) {
document.getElementById(di
}
else if (sel.selectedIndex == 0) {
document.getElementById(di
} else {
//We have to loop
var i = 0;
var selField;
while (selField = document.getElementById('s
if (selField.selectedIndex == 1) {
return;
}
}
document.getElementById(di
}
}
}
</script>
</head>
<body>
<%
checkTitle="Checklist"
Dim step(13)
step(0) = "Confirm incident"
step(1) = "Confirm product."
step(2) = "Confirm has been installed"
step(3) = "Confirm the Environment"
step(4) = "Confirm is they have selected Test Mode that user ids have been provided."
step(5) = "Confirm that a test account has been provided."
step(6) = "Confirm that the test account can be logged into successfully
step(7) = "Confirm that the vendor has sent a confirmation email "
step(8) = "Confirm Form is attached."
step(9) = "Confirm Form is complete."
step(10) = "Confirm client form is attached."
step(11) = "Confirm client form is complete."
step(12) = "Confirm the location of the button."
step(13) = "Confirm that a button color has been selected." &_
%>
<span class="normalLgBox" style="margin: 10px;">
<div class="ms-WPHeader ms-WPTitle">
</div>
<div class="normalLgBoxContent"
<center>
<strong><span class="largeText"><% Response.Write(checkTitle)
<p>
<form method="post" name="myForm">
<table width="80%" cellspacing="" celpadding="5" align="center">
<% if request.form("status") <> "" then %>
<tr>
<td class="Strong" valign="top">Results:</td>
<td class="Strong" valign="top">
<%
dim a
dim passOrFail
passOrFail = "<font size=""+1"" color=""green"">PASS</font
for a = 0 to ubound(step)
if request.form("status") <> "" then
if request.form("question" & (a)) = "FAIL" then
passOrFail = "<font size=""+1"" color=""red"">FAIL</font>"
end if
end if
Next
Response.Write(passOrFail)
%>
</td>
</tr>
<tr>
<td class="Strong" valign="top">Date:</td>
<td class="normal" valign="top">
<script type="text/javascript">
var d=new Date()
//var weekday=new Array("Sunday","Monday","T
var monthname=new Array("01","02","03","04",
//document.write(weekday[d
document.write(monthname[d
document.write(d.getUTCDat
document.write(d.getFullYe
document.write(d.getHours(
</script>
</td>
</tr>
<tr>
<td class="Strong" valign="top">Tested By:</td>
<td class="normal" valign="top"><%= request.form("submitter") %></td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<% end if %>
<tr>
<td colspan="2"><div id="display"></div></td>
</tr>
<tr>
<td class="ms-WPHeader ms-WPTitle">PASS / FAIL</td>
<td class="ms-WPHeader ms-WPTitle" width="80%">Step</td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<%
dim i
for i = 0 to ubound(step)
if request.form("status") <> "" then
%>
<tr>
<td valign="top" class="strong">
<!-- RESULTS GO HERE (red if FAIL or INCOMPLETE) -->
<% if request.form("question" & (i)) = "FAIL" then %>
<font color="Red"><%= request.form("question" & (i)) %></font>
<% end if
if request.form("question" & (i)) = "N/A" then %>
<font color="#FF8800"><%= request.form("question" & (i)) %></font>
<% end if
if request.form("question" & (i)) = "PASS" then %>
<font color="Green"><%= request.form("question" & (i)) %></font>
<% end if %>
</td>
<td class="normal">
STEP: <% Response.Write(step(i)) %>
<!-- NOTES GO HERE IF ENTERED -->
<% if request.form("question" & (i)) = "FAIL" and request.form("step" & (i) & "txt") <> "NOTES:" and request.form("step" & (i) & "txt") <> "" then %>
<br><br>
<b>NOTES:</b> <%= request.form("step" & (i) & "txt") %>
<% end if %>
</td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<% else %>
<tr>
<td valign="top" class="strong">
<select name="question<% Response.Write(i) %>" onChange="displayMessage(t
<option value="NOT TESTED"></option>
<option value="PASS">PASS</option>
<option value="FAIL">FAIL</option>
<option value="N/A">N/A</option>
</select></td>
<td class="normal">
<% Response.Write(step(i)) %><br><br>
<textarea cols="70%" rows="5" name="step<% Response.Write(i) %>txt" id="step<% Response.Write(i) %>txt" style="display: none;" onfocus='if (this.value=="NOTES:") this.value="";'>NOTES:</te
</td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<%
end if
Next
%>
</table>
<input type="hidden" name="status" value="submitted">
<%
if request.form("status") <> "submitted" then
%>
<p>
<b>Submitted By:</b> <input type="text" name="submitter" value="<%= getCookie("nfront-intranet
<input type="button" value="Submit" class="button" style="background-color: <%= Application("color2") %>; color: #ffffff; font-weight: bold;" onMouseOver="change('<%= Application("color1") %>');" onMouseOut="change('<%= Application("color2") %>');" onClick="checkForm();">
<% else %>
<input type="button" value="BACK" class="button" style="background-color: <%= Application("color2") %>; color: #ffffff; font-weight: bold;" onMouseOver="change('<%= Application("color1") %>');" onMouseOut="change('<%= Application("color2") %>');" onClick="javascript:histor
<% end if %>
</form>
</center>
ASKER
Ok, so I was just staring at code for too long. I missed deleting a quotation mark when removing the onfocus='this.value="";' - sorry! Your solutions were perfect, I am not.
ASKER