struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Lucas Gonzalez Pearson" <lucas.gonza...@convergia.com.ar>
Subject Re: Dynamically Display in the Textarea Based on Menu Selection Made by Users
Date Fri, 24 Sep 2004 21:55:07 GMT
Easy...
everything has already been fetched before...

take a look at the source ( no copyrights violation intended ):

 <script>
 var programSelectionTable;
 var programDescription;
 var programSubProgramSelect;
 var programHigestLevel;
  function showOtherFields(n){

   var selectedProgramName =
document.getElementById('selectBox'+n).options[document.getElementById('sele
ctBox'+n).selectedIndex].value;
    if (selectedProgramName=="")
    {
     document.getElementById('programDescritionText'+n).innerHTML =
programDescription;
     document.getElementById('subProgramSelect'+n).innerHTML =
programSubProgramSelect;
     document.getElementById('highestLevelRep'+n).innerHTML =
programHigestLevel;
     document.getElementById('hiddenProgramName'+n).innerHTML = "";
     document.getElementById('yesButton'+n).disabled=true;
     document.getElementById('noButton'+n).disabled=true;

    }
    else {
     getProgramDescrption(selectedProgramName,n);
     document.getElementById('subProgramSelect'+n).innerHTML =
document.getElementById(selectedProgramName+"CNameSelect").value;
     document.getElementById('highestLevelRep'+n).innerHTML =
document.getElementById(selectedProgramName+"HighestLevel").value;
     document.getElementById('hiddenProgramName'+n).innerHTML =
document.getElementById(selectedProgramName+"HiddenProgram").value;
     document.getElementById('yesButton'+n).disabled=false;
     document.getElementById('noButton'+n).disabled=false;
    }

  }
  function showNextSection(n){
   document.getElementById('sectionJSOn'+n).innerHTML =
createProgramSelectionTable(n);
   document.getElementById('sectionJSOn'+n).style.display="";
  }

  function createProgramSelectionTable(n){
   var nextSectionToShow = n+1;
   programSelectionTable= "<table border=\"0\"  cellspacing=\"1\"
cellpadding=\"4\">";
   programSelectionTable += "<tr>";
   programSelectionTable += "<td class=\"label\" align=\"right\">Select
Program Group:<img src=\"../images/asterik.gif\">";
   programSelectionTable += "</td>";
   programSelectionTable += "<td class=\"inputArea\" > ";
   programSelectionTable += "<select onchange=\"showOtherFields("+n+")\"
id=\"selectBox"+n+"\" class=\"inputArea\">";
   programSelectionTable += "<option value=\"\">Select from list</option>";
   programSelectionTable += "<option value=\"cit\">Citizen Action</option>";
   programSelectionTable += "<option value=\"cip\">Critical
Infrastructure</option>";
   programSelectionTable += "<option value=\"eoc\">Emergency
Management</option>";
   programSelectionTable += "<option value=\"fire\">Fire &amp; Emergency
Medical Services</option>";
   programSelectionTable += "<option value=\"gov\">Government
Operations</option>";
   programSelectionTable += "<option value=\"le\">Law Enforcement -
Commissioned Officers Only</option>";
   programSelectionTable += "<option value=\"ps\">Private Sector</option>";
   programSelectionTable += "<option value=\"ph\">Public Health</option>";
   programSelectionTable += "</select>";
   programSelectionTable += "</td>";
   programSelectionTable += "</tr>";
   programSelectionTable += "<tr valign=\"top\">";
   programSelectionTable += "<td class=\"label\">Program Group
Description:";
   programSelectionTable += "</td>";
   programSelectionTable += "<td class=\"inputArea\" > ";
   programSelectionTable += "<div id=\"programDescritionText"+n+"\"
style=\"display:\">";


    programDescription = "<textarea rows=\"4\" cols=\"57\"
readonly=\"true\">";
    programDescription += "</textarea>";


   programSelectionTable += programDescription ;
   programSelectionTable += "</div>";
   programSelectionTable += "</td>";
   programSelectionTable += "</tr> ";


   programSelectionTable += "<tr>";
   programSelectionTable += "<td class=\"label\">Select Sub Program
Group:<img src=\"../images/asterik.gif\">";
   programSelectionTable += "</td>";
   programSelectionTable += "<td class=\"inputArea\" > ";
   programSelectionTable += "<div id=\"subProgramSelect"+n+"\">";


    programSubProgramSelect = "<select disabled=\"true\"
class=\"inputArea\">";
    programSubProgramSelect += "<option value=\"\">Select from list, or
Select \"None\" or \"Other\"</option>";
    programSubProgramSelect += "</select>";

   programSelectionTable += programSubProgramSelect ;
   programSelectionTable += "</div>";
   programSelectionTable += "</td>";
   programSelectionTable += "</tr> ";
   programSelectionTable += "<tr>";
   programSelectionTable += "<td class=\"label\" align=\"left\" nowrap
colspan=\"2\">Select Highest Level of Responsibilty:<img
src=\"../images/asterik.gif\"></td>";
   programSelectionTable += "</tr>";
   programSelectionTable += "<tr>";
   programSelectionTable += "<td colspan=\"2\">";
   programSelectionTable += "<div id=\"highestLevelRep"+n+"\">";


    programHigestLevel = "<table border=\"0\" cellpadding=\"4\"
cellspacing=\"1\">";
    programHigestLevel += "<tr>";
    programHigestLevel += "<td class=\"inputArea\"><input type=\"radio\"
style=\"border: 0px\" disabled=\"true\" >International</td>";
    programHigestLevel += "<td class=\"inputArea\"><input type=\"radio\"
style=\"border: 0px\" disabled=\"true\" >Federal</td>";
    programHigestLevel += "<td class=\"inputArea\"><input type=\"radio\"
style=\"border: 0px\" disabled=\"true\" >Regional</td>";
    programHigestLevel += "<td class=\"inputArea\"><input type=\"radio\"
style=\"border: 0px\" disabled=\"true\" >State</td>";
    programHigestLevel += "</tr> ";
    programHigestLevel += "<tr>";
    programHigestLevel += "<td class=\"inputArea\"><input type=\"radio\"
style=\"border: 0px\" disabled=\"true\">County</td>";
    programHigestLevel += "<td class=\"inputArea\"><input type=\"radio\"
style=\"border: 0px\" disabled=\"true\" >Local</td>";
    programHigestLevel += "<td class=\"inputArea\"><input type=\"radio\"
style=\"border: 0px\" disabled=\"true\" >City</td>";
    programHigestLevel += "<td class=\"inputArea\"><input type=\"radio\"
style=\"border: 0px\" disabled=\"true\" >Tribal</td>";
    programHigestLevel += "</tr>";
    programHigestLevel += "</table>";


   programSelectionTable += programHigestLevel;
   programSelectionTable += "</div>";
   programSelectionTable += "</td>";
   programSelectionTable += "</tr>";
   programSelectionTable += "<tr>";
   programSelectionTable += "<td colspan=\"2\" class=\"label\">Are you
eligible for another program group? &nbsp;&nbsp;&nbsp;";
   programSelectionTable += "<input type=\"button\" id=\"yesButton"+n+"\"
class=\"button\" value=\"Yes\"
onclick=\"showNextSection("+nextSectionToShow+")\"
disabled=\"true\">&nbsp;&nbsp;&nbsp;<input class=\"button\"
id=\"noButton"+n+"\" type=\"button\" value=\"No\" disabled=\"true\">";
   programSelectionTable += "</td>";
   programSelectionTable += "</tr>";
   programSelectionTable += "<tr>";
   programSelectionTable += "<td colspan=\"2\">";
   programSelectionTable += "<div id=\"hiddenProgramName"+n+"\"></div>";
   programSelectionTable += "<hr />";
   programSelectionTable += "</td>";
   programSelectionTable += "</tr>";
   programSelectionTable += "</table>";

   return programSelectionTable;

  }

  function getProgramDescrption(selectedProgramName, n){
   var programDescriptionText="<textarea rows=\"4\" cols=\"57\"
readonly=\"true\">";


   if (selectedProgramName=="cit") {
    programDescriptionText+="Individuals who currently assist in their
community or would be available in case of an emergency. Often their
participation is in a volunteer capacity and they may be involved in a
structured organization such as Citizen Corps or Red Cross or participate in
ad hoc groups. Many citizens are involved in organized volunteer activities
on a full time basis, while others are only available as needed.";
   }

   else if (selectedProgramName=="cip"){
    programDescriptionText+="Individuals whose professional responsibilities
include ownership, management, operations or protection of the critical
infrastructures of the United States. HSIN-CI recognizes the following as
critical infrastructures: Agriculture & Food; Banking & Finance; Chemical &
HAZMAT; Defense Industry; Education; Emergency Services; Energy; Government
Operations; Information Technology; Law Enforcement; National Monuments and
Icons; Postal & Shipping; Private Sector; Public Health; Transportation;
Water/Waste Water.";
   }
   else if (selectedProgramName=="eoc"){
    programDescriptionText+="Individuals responsible for Emergency
Management : prevention, response and mitigation. This Program Group
includes federal, state, local, private and volunteer emergency management
operations. ";
   }
   else if (selectedProgramName=="fire"){
    programDescriptionText+="Individuals responsible for Fire & Emergency
Medical Services : prevention, response and mitigation. This Program Group
includes federal, state, local, private, volunteer and tribal fire and
emergency management operations.";
   }
   else if (selectedProgramName=="gov"){
    programDescriptionText+="Individuals representing government agencies at
the Federal, Regional, State, County, Local, City and Tribal levels.";
   }
   else if (selectedProgramName=="le"){
    programDescriptionText+="This Program Group is restricted to active
Commissioned Peace officers from federal, regional, state, county, local,
city, tribal and private agencies. ";
   }
   else if (selectedProgramName=="ps"){
    programDescriptionText+="Individuals representing corporations,
associations and industry units who have an inherent or developed experience
basis from which to draw on. Typically, these are decision makers and
include those who need to know and those who need to act. ";
   }
   else if (selectedProgramName=="ph"){
    programDescriptionText+="Individuals representing hospitals, doctors,
pharmacists, emergency clinics and so on. The individuals represent health
care corporations and associations as well as ancillary industries that are
focused on public health. ";
   }

   programDescriptionText+="</textarea>";
   document.getElementById('programDescritionText'+n).innerHTML =
programDescriptionText;
   document.getElementById('programDescritionText'+n).style.display="";


  }
  </script><script language="JavaScript">


Hope it helps
Lucas

----- Original Message ----- 
From: "Caroline Jen" <jiapei_jen@yahoo.com>
To: <struts-user@jakarta.apache.org>
Sent: Friday, September 24, 2004 6:43 PM
Subject: Dynamically Display in the Textarea Based on Menu Selection Made by
Users


> It seems to me that it can be done.  Would you please
> just take a look at
> https://www.swern.gov/forms/enrollmeform.php
>
> and scroll down a little below half way.  There is a
> drop-down menu for the 'Select Program Group'.  And
> there is a textarea right below that drop-down menu.
>
> Simply select a group from the drop-down menu, you
> will see a description of that program group appears
> in the textarea.
>
> I wonder how it is done.  Because I am trying to
> search the database tables upon selection is made by
> users.  And then, display what I find in the database
> in the textarea.
>
>
>
> __________________________________
> Do you Yahoo!?
> Yahoo! Mail - Helps protect you from nasty viruses.
> http://promotions.yahoo.com/new_mail
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message