Advertisement

10.08.2003 at 03:40PM PDT, ID: 20761207
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.4

Hiding text along with fields

Asked by truckirwin in JavaScript

Tags:

Hi All,

I have a form with a couple of list fields, if the user needs to add something that is not on the list I have a choice value "other", on change, a text field is displayed for typed input.

Problem : Can I hide the associated text with the field?  And how, with the script I have...?

Sorry for the big dump, there is lots of validation/translation for the rest of the form not included here.  I have stripped out most of the HTML, but left the JS so as not to jip anyone!  View it in a browser, the form is very simple...

Thanks, Truck

Here is the HTML:


<html>
<head>
<title>TESSIE Instructor Console</title>
<script language="JavaScript" >
<!--
function xsl() {
xmlSource = new ActiveXObject("Microsoft.xmldom");
xmlSource.async = false;
xmlSource.load("xml/header.xml");
xslStyle = new ActiveXObject("Microsoft.xmldom");
xslStyle.async = false;
xslStyle.load("xml/header.xsl");
document.all.item("xslHeader").innerHTML =
xmlSource.transformNode(xslStyle.documentElement);
}


//-->
</script>
<style type="text/css">
.invisible { visibility: hidden;}
.visible {visibility: visible;}
</style>
<SCRIPT>
<!-- Hide from older browsers

function DateToday() {
var Today=new Date();
var ThisDay=Today.getDate();
var ThisMonth=Today.getMonth()+1;
var ThisYear=Today.getFullYear();
return ThisMonth+"-"+ThisDay+"-"+ThisYear;
}

function today() {
document.Form_cust.date.value=DateToday();
}
function day_of_class() {
document.Form_cust.day_of_class.value=getCookie('day_of_class');
}
//Stop hiding -->
</SCRIPT>
<SCRIPT LANGUAGE = "JavaScript">
<!-- Begin
var expDays = 90; // set this value to however many days you want your cookies to last

function setCookie(name, val)
{
var exp = new Date()
var cookieTimeToLive = exp.getTime() + (expDays * 24 * 60 * 60 * 1000)
exp.setTime(cookieTimeToLive)
document.cookie = name + "=" + escape(val) + "; expires=" + exp.toGMTString()
}
function getCookie(name)
{
var cookieNameLen = name.length
var cLen = document.cookie.length
var i = 0
var cEnd
var myStringToReturn
var myStringToReturnLen
while (i < cLen)
{
var j = i + cookieNameLen
if (document.cookie.substring(i,j) == name)
{
cEnd = document.cookie.indexOf(";",j)
if (cEnd == -1)
{
cEnd = document.cookie.length
}
myStringToReturn = unescape(document.cookie.substring(j,cEnd))
myStringToReturnLen = myStringToReturn.length
myStringToReturn = myStringToReturn.substring(1,myStringToReturnLen+1)
return myStringToReturn
}
i++
}
return ""
}

function setDefaultValues()
{
var strCookieName, strCookieVal
var iFormsCount = 0
var iElementsCount = 0
for(iFormsCount=0;iFormsCount < document.forms.length;iFormsCount++)
{
for(iElementsCount=0;iElementsCount < document.forms[iFormsCount].elements.length;iElementsCount++)
{
strCookieName = document.forms[iFormsCount].elements[iElementsCount].name
strCookieVal = getCookie(strCookieName)
if (strCookieVal != null && !(isNaN(strCookieVal)) && strCookieVal != '')
{
document.forms[iFormsCount].elements[iElementsCount].selectedIndex = strCookieVal
}
}
}
}

function replaceChars( foo )
{
 for( i=0; i<foo.length; i++ )
 {
   var c = foo.charAt( i );
   if( c == '&' )
   {
     foo = foo.substring( 0 ,i  ) + "&amp;" + foo.substring( i + 1, foo.length );
   } else if( c == '<' )
   {
     foo = foo.substring( 0 ,i  ) + "&lt;" + foo.substring( i + 1, foo.length );
   } else if( c == '>' )
   {
     foo = foo.substring( 0 ,i  ) + "&gt;" + foo.substring( i + 1, foo.length );
   }
  }
 return foo;
}

function translate()
{
Form_cust.customer.value = replaceChars( Form_cust.customer.value );
}
// End -->
</SCRIPT>
<script language="JavaScript">
<!--
function chkOther(selval, field)
{
if (!selval) return;
else {
var bWhich = (selval == 'other');
field.className = (bWhich) ? 'visible' : 'invisible';

field.disabled = !bWhich;
if (bWhich) field.value = '';
if (bWhich) field.focus();
;
}
}

function runSubmit (form, button) {

Ctrl = form.instructor.selectedIndex
if (form.instructor.options[Ctrl].value == "") {
validatePromt(Ctrl,"Please Select Your Name");
return (false);
}


Ctrl = form.region.selectedIndex
if (form.region.options[Ctrl].value == "")
{
validatePromt(Ctrl,"Please Select Your Region");
return (false);
}
else {
setCookie('region',form.region.selectedIndex);
}

Ctrl = form.date;
if (Ctrl.value =="") {
validatePromt(Ctrl,"Please Enter a Date");
return (false);
}
else {setCookie('date', DateToday());}

Ctrl = form.course.selectedIndex
if (form.course.options[Ctrl].value == "") {
validatePromt(Ctrl,"Please Select a Course");
return (false);
}
Ctrl = form.day_of_class;
if (Ctrl.value == "") {
validatePromt(Ctrl,"Please select the number of days.");
return (false);
}
else{ setCookie('day_of_class',form.course.options[form.course.selectedIndex].value1)}

Ctrl = form.location2;
if (Ctrl.value == "none") {
validatePromt(Ctrl,"Please select a location.");
return (false);
}
else if (form.location2.value!="other"){
form.location.value=form.location2.value;
}
if ((form.location2.value=="other") && (form.customer.value == "")) {
validatePromt(Ctrl,"Please Enter the Customer Information.");
return (false);
}
else if ((form.location2.value=="other") && (form.customer.value != "")) {
form.location.value=form.customer.value;
}

var check_date = getCookie('date')
var check_inst =getCookie('instructor')
var check_course =getCookie('course')

if (  ( form.instructor.selectedIndex == check_inst  ) &&  ( form.course.selectedIndex == check_course ) &&(check_date == DateToday()) )
if (confirm("\nYou're about to submit the form. It appears you have already saved \na class with this configuration.  If you continue, saved data could be lost. \n\nClick on OK to submit.\n\nClick on Cancel to abort."))
{
alert("\nYour submission will now be made to data file, Thank you!");
document.Form_cust.submit();
return (true);
}
else
{
alert("\nYou have chosen to abort the submission.");
return (false);      
}
else {document.Form_cust.submit();
setCookie('instructor',form.instructor.selectedIndex);
setCookie('course',form.course.selectedIndex);
return (true); }
}

function validatePromt(Ctrl, PromtStr) {
alert (PromtStr);
// Ctrl.focus();
return(true);
}

function ShowAlert()
{
var check_date = getCookie('date')
var check_inst =getCookie('instructor')
var check_course =getCookie('course')
alert (document.cookie)
alert (document.Form_cust.course.selectedIndex)
 if (  ( document.Form_cust.instructor.selectedIndex == check_inst  ) &&  ( document.Form_cust.course.selectedIndex == check_course ) &&(check_date == DateToday()) )
{ alert ("\nClass Date:",check_course)
}
else {alert (document.Form_cust.course.selectedIndex)}
}

function MM_findObj(n, d) { //v4.0
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && document.getElementById) x=document.getElementById(n); return x;
}
//-->
</script>
<script language="JavaScript1.2">
<!--

function refresh()
{
window.location.reload( false );
}
//-->
</script>
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//-->
</script>
</head>
<LINK href="standard.css" type=text/css rel=stylesheet>
<body onLoad="xsl();setDefaultValues();today();day_of_class()">
<form name="Form_cust" method="post" action="/servlet/InstSetup" >
  <table width="59%" border="0" cellspacing="0" cellpadding="1">
    <tr>
      <td><strong>Instructor Name:&nbsp;</strong> </td>
      <td><strong>Please enter name:</strong></td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td><select name="instructor2" onChange="chkOther(options[selectedIndex].value,instructor)">
          <option value="" selected>Select Your Name
          <option value="Sally">Sally</option>
          <option value="Joe">Joe</option>
          <option value="other">Not&nbsp;on&nbsp;List?</option>
        </select> </td>
      <td><input type="text" value="Type your name here." name="instructor" class="invisible" disabled="disabled"></td>
      <td>&nbsp;</td>
    </tr>
    <script>
function openObject(someID)
{
document.getElementById(someID).style.visibility = 'visible';
}
</script>
    <tr>
      <td width="156"><b>Location:</b> <input type="hidden" name="location"> </td>
      <td width="198"><b>Customer Info:</b> </td>
      <td >&nbsp;</td>
    </tr>
    <tr>
      <td height="24"> <select name="location2" onChange="chkOther(options[selectedIndex].value,customer)">
          <option value="none" selected>Choose Location</option>
          <option value="TLC-PA-Sapphire">TLC-PA-Sapphire</option>
          <option value="TLC-PA-Emerald">TLC-PA-Emerald</option>
          <option value="other">On-Site(Add Cust)</option>
        </select> </td>
      <td width="198"><input type="text" value="Please enter customer name" label="AAA" name="customer" class="invisible"disabled="disabled"></td>
      <td ><input name="Button" type="button"
onClick="translate(); runSubmit(this.form,this); " value="Setup"></td>
    </tr>
  </table>
  </form>
</body>
</html>Start Free Trial
[+][-]10.08.2003 at 03:53PM PDT, ID: 9517115

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]10.08.2003 at 05:33PM PDT, ID: 9517493

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]10.08.2003 at 08:55PM PDT, ID: 9518184

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: JavaScript
Tags: selval
Sign Up Now!
Solution Provided By: jaysolomon
Participating Experts: 3
Solution Grade: A
 
 
[+][-]02.10.2004 at 07:39AM PST, ID: 10323069

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32