Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Onfocus errors

Posted on 2007-10-15
6
Medium Priority
?
317 Views
Last Modified: 2007-10-15
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="";'>NOTES:</textarea>
0
Comment
Question by:Bertrendy
  • 3
  • 2
6 Comments
 
LVL 17

Accepted Solution

by:
gops1 earned 1000 total points
ID: 20080290
Remove this line, if you do not want this to happen

onfocus='this.value="";'
0
 
LVL 48

Assisted Solution

by:hernst42
hernst42 earned 1000 total points
ID: 20080300
Try:

onfocus='if (this.value=="NOTES:") this.value="";'

So the field gets only cleared if it contains the default.
0
 

Author Comment

by:Bertrendy
ID: 20080341
When I enter either one of those into the code, nothing changes. The text still disappears when it is first clicked on or when you re-vist the textarea.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 17

Expert Comment

by:gops1
ID: 20080352
Show us what have you done till now
0
 

Author Comment

by:Bertrendy
ID: 20080412
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- #include virtual="/masterincludes/intranet-functions.inc" -->
<html>
<head>
<title>
Technical Support
</title>
<!-- #include virtual="/masterincludes/css-js.inc" -->

<script language="JavaScript">
function checkForm() {
      var b = document.getElementsByTagName('select');
      for (i = 0; i < b.length ; i++) {
            if (eval("document.myForm.question" + i + ".value") == "NOT TESTED") {
                  alert("Please COMPLETE step #" + (i + 1) + " to submit.");
                  eval("document.myForm.question" + i + ".focus()");
                  return false;
            }
      }
      document.myForm.submit();
}

function openCalendarWindow(formVar) {
      newWin = window.open("/calendar-popup.asp?formVar=" + formVar,"cal","dependent=yes,width=210,height=210,screenX=200,screenY=300,titlebar=yes");
}

function openWinSmall(pagename) {
      smallWin2=open(pagename,"smallwin2","width=500,height=500,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no");
}

function displayMessage(sel,div) {
    var displayArea = document.getElementById('display');
    if (displayArea) {
        if (sel.selectedIndex == 2) {
            document.getElementById(div).style.display = 'block';
        }
            else if (sel.selectedIndex == 0) {
            document.getElementById(div).style.display = 'none';
        } else {
            //We have to loop
            var i = 0;
            var selField;
            while (selField = document.getElementById('select' + i)) {
                if (selField.selectedIndex == 1) {
                    return;
                }
            }
            document.getElementById(div).style.display = '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","Tuesday","Wednesday","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.getUTCMonth()] + "/")
            document.write(d.getUTCDate() + "/")
            document.write(d.getFullYear() + " ")
            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">&nbsp;</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">&nbsp;</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">&nbsp;</td>
      </tr>
      
      
      <% else %>
      
      <tr>
            <td valign="top" class="strong">
            <select name="question<% Response.Write(i) %>" onChange="displayMessage(this, '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:</textarea>
            </td>
      </tr>
      <tr>
            <td colspan="2">&nbsp;</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:history.back();">
      <% end if %>
      </form>
      </center>
0
 

Author Comment

by:Bertrendy
ID: 20080556
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.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question