Solved

Need help with javascript

Posted on 2004-03-24
10
155 Views
Last Modified: 2013-12-24
I am trying to perform an onclick function for a select and a radio button.  I want the two to work together to provide the criteria for the textarea.  I do not want the page to submit.  This is what I have so far, and it is not working.  Any suggestions?

<html>
<head>
<title></title>
<script type="text/javascript">
<!--
var setTxtAreaValue = function(theForm){
     if(theForm["keyword"].selectedIndex == 1){
          theForm["trait"][0].click();
          theForm["traitdescription"].value = "<cfoutput query="getsugobs">#PosTrait#</cfoutput>";
     } else {
          theForm["trait"][1].click();
          theForm["traitdescription"].value = "<cfoutput query="getsugobs">#NegTrait#</cfoutput>";
     }
  }            
// -->
</script>
</head>
<body>
<cfquery datasource="btadb" name="getsugobs">
SELECT id, keyword, postrait, negtrait
FROM observat
WHERE accountnbr = #session.accountnbr#
</cfquery>

<form name="traits" action="" method="post">
      <tr>
         <td colspan="6">Suggested Performance Observations:</td>
         </tr>
             <tr>
               <td>
          <table>
             <tr>
               <td>
                 <select name="keyword" style="width:150px" onChange="setTxtAreaValue(this.form);">
            <cfoutput query="getsugobs">
               <option value="#id#">#keyword#</option>
            </cfoutput>
                 </select>
               </td>
             </tr>
             <tr>
               <td valign="top">
                 <input type="radio" name="trait" value="1" onClick="setTxtAreaValue(this.form);" checked>Positive               </td>
             </tr>
             <tr>
               <td valign="top">
                 <input type="radio" name="trait" value="2" onClick="setTxtAreaValue(this.form);">Negative               </td>
             </tr>
            </table>
            </td>
            <td rowspan="3" valign="top">
            <cfoutput query="getsugobs">
            <cfif #id# eq #url.keyword#>
            <cfif #url.trait# eq 1>
                  <textarea name="traitdescription" cols="75" rows="8" disabled>#trim(postrait)#</textarea>
            <cfelse>
                  <textarea name="traitdescription" cols="75" rows="8" disabled>#trim(negtrait)#</textarea>
            </cfif>
            </cfif>
            </cfoutput>            
            </td>
        </tr>
</form>
0
Comment
Question by:swartout
  • 3
  • 3
10 Comments
 
LVL 9

Expert Comment

by:CFDevHead
ID: 10670061
who do you want the radio and selectbox to work together?
0
 

Author Comment

by:swartout
ID: 10670092
The select lets the user select the "keyword" and the radio lets them view either the positive or the negative for that keyword.  I want it to default to the positive, and then if the user radios the negative, then I want the negative to be in the textarea.

0
 
LVL 9

Expert Comment

by:CFDevHead
ID: 10670146
can you post the compiled code?
0
Connect further...control easier

With the ATEN CE624, you can now enjoy a high-quality visual experience powered by HDBaseT technology and the convenience of a single Cat6 cable to transmit uncompressed video with zero latency and multi-streaming for dual-view applications where remote access is required.

 

Author Comment

by:swartout
ID: 10670166
<html>
<head>
<title></title>
<script type="text/javascript">
<!--
var setTxtAreaValue = function(theForm){
     if(theForm["keyword"].selectedIndex == 1){
          theForm["trait"][0].click();
          theForm["traitdescription"].value = "<#PosTrait#>";
     } else {
          theForm["trait"][1].click();
          theForm["traitdescription"].value = "You perform well under normal circumstances but have some difficulty handling new developments without assistance.  You would make a greater contribution if you took more initiative in tackling new problems on your own and solving problems on your own, seSpeak to express, not impress.  Using complicated words and clever sayings only adds to the confusion that happens when communicating with others.  Simplify your communications.  Edit your communications with simplification in mind.We encourage you to useYou are a satisfactory performer.  You usually complete regular work projects on schedule.  You are competent in solving problems and making decisions.  You are generally effective working within your own group as well as within the entire organization.  You are generally reliable in dealing with customers, but you sometimes neglect to follow up to make sure that commitments are met, affecting your credibility and the company's reputation.  You need to make it a priority to follow through on customer commYou are a competent decision maker but tend to delay action until pressed to make a decision.  You would improve your productivity by making decisions sooner.You are capable of making good decisions but sometimes take a hurried approach.  By rushing imporYou are not always on top of deadlines and, in some cases, need to be reminded of due dates and responsibilities.  You need to become more consistent about meeting deadlines on your own, prioritizing your work and managing your time more efficiently.You cYou are a consistent, dependable team member, but could become an even stronger contributor by initiating and driving new approaches.  When you feel confident about an idea, you should move forward.You have contributed some new ideas in the past, and we wInnovation is one of the components of our company's success, so it is important for each of us to promote creativity and risk-taking.  You could help in this area by communicating the direction and value of change and by getting behind the people who creYour enthusiasm for your ideas is desirable and appreciated, but there are times when you need to listen more attentively to the opinions of others.We encourage you to seek out feedback from your peers as a way of improving your work.  Feel free to come tWhile you are generally thorough and produce good quality work, you have occasionally shown a lack of attention to critical issues and details in your areas of responsibility.  You would be more effective if you could be relied on to provide sound informaYou sometimes rush and make poor judgment calls in high-pressure situations.  You would make the most of your decisions and actions by relying more on your past experience.  Your judgement is often overly influenced by factors that are only indirectly relYou think through your arguments but don't always give others time to come around to your point of view.  You sometimes become impatient, which tends to foster unnecessary opposition to your points. You would be more successful if you were more patient inIt is important for managers to give frequent performance feedback to employees and take an active interest in their progress.  You have made some progress in this area but could be more consistent.  By giving more positive recognition for good performancYou have shown an interest in your employees but have not done what you could to set developmental goals and provide structured guidance.  We would like to see you work more closely with individuals to create developmental goals and assign related projectYou normally develop effective plans.  However, when dealing with complex issues, you have difficulty identifying appropriate tasks and goals.  To improve your productivity, be more careful in dealing with the component parts of more complex plans.You areWhile you generally keep track of new developments, you sometimes fail to anticipate potential problems.  You would be more able to take corrective action if you were more attentive to situations where problems can be anticipated.You usually define probleYou sometimes do not complete your work on time.  As a result, team members must pitch in to help complete your work.  You need to be more conscientious about completing your work on time and handling your fair share of the workload.You are generally a coWhile you are generally a productive worker, you rarely interact or make contributions in a group setting.  You would be a more productive contributor if you assumed an active role in the group's activities.You are usually effective in group settings but ";
     }
  }            
// -->
</script>
</head>
<body>
<form name="traits" action="" method="post">
      <tr>
         <td colspan="6">Suggested Performance Observations:</td>
         </tr>
             <tr>
               <td>
          <table>
             <tr>
               <td>
                 <select name="keyword" style="width:150px" onChange="setTxtAreaValue(this.form);">
           
               <option value="1">Adaptability</option>
           
               <option value="2">Communication</option>
           
               <option value="3">Performance Overview</option>
           
               <option value="4">Customer Focus</option>
           
               <option value="5">Decision Making</option>
           
               <option value="6">Dependability</option>
           
               <option value="7">Initiative</option>
           
               <option value="8">Innovation</option>
           
               <option value="9">Interpersonal Skills</option>
           
               <option value="10">Job Knowledge</option>
           
               <option value="11">Judgment</option>
           
               <option value="12">Leadership</option>
           
               <option value="13">Managing Performance</option>
           
               <option value="14">People Development</option>
           
               <option value="15">Planning/Organizing</option>
           
               <option value="16">Problem Solving</option>
           
               <option value="17">Productivity</option>
           
               <option value="18">Teamwork</option>
           
                 </select>
               </td>
             </tr>
             <tr>
               <td valign="top">
                 <input type="radio" name="trait" value="1" onClick="setTxtAreaValue(this.form);" checked>Positive               </td>
             </tr>
             <tr>
               <td valign="top">
                 <input type="radio" name="trait" value="2" onClick="setTxtAreaValue(this.form);">Negative               </td>
             </tr>
            </table>
            </td>
            <td rowspan="3" valign="top">
            
            
                  <textarea name="traitdescription" cols="75" rows="8" disabled>You do a terrific job of dealing with change and rarely let it interfere with your ability to meet your goals.  In response to rapidly changing circumstances, you use your judgment, experience, and positive outlook to achieve desired results.  If necessar</textarea>
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
                        
            </td>
        </tr>
</form>
0
 
LVL 9

Expert Comment

by:CFDevHead
ID: 10670256
explain a little more in depth about what the select box needs to do
0
 

Author Comment

by:swartout
ID: 10670313
The select box gives the user the choice of different areas for a performance evaluation, the radio button is the option of the positive observations and the negative observations.  The textarea is the verbage of the positive or negative observation.

This is used to give the reviewer tips on writing their observations for the reviewee.
0
 
LVL 11

Accepted Solution

by:
hart earned 500 total points
ID: 10693836
try this and let me know

<cfquery datasource="btadb" name="getsugobs">
SELECT id, keyword, postrait, negtrait
FROM observat
WHERE accountnbr = #session.accountnbr#
</cfquery>
<html>
<head>
<title></title>
<script type="text/javascript">
<!--
function setTxtAreaValue(theForm){
    if(theForm["keyword"].selectedIndex == 1){
         theForm["trait"][0].checked = true;
         theForm["traitdescription"].value = '<cfoutput query="getsugobs">#PosTrait#</cfoutput>';
    } else {
         theForm["trait"][1].checked = true;
         theForm["traitdescription"].value = '<cfoutput query="getsugobs">#NegTrait#</cfoutput>';
    }
 }            
// -->
</script>
</head>
<body>
<form name="traits" action="" method="post">
     <tr>
       <td colspan="6">Suggested Performance Observations:</td>
       </tr>
          <tr>
            <td>
        <table>
          <tr>
            <td>
              <select name="keyword" style="width:150px" onChange="setTxtAreaValue(this.form);">
           <cfoutput query="getsugobs">
            <option value="#id#">#keyword#</option>
           </cfoutput>
              </select>
            </td>
          </tr>
          <tr>
            <td valign="top">
              <input type="radio" name="trait" value="1" onClick="setTxtAreaValue(this.form);" checked>Positive             </td>
          </tr>
          <tr>
            <td valign="top">
              <input type="radio" name="trait" value="2" onClick="setTxtAreaValue(this.form);">Negative             </td>
          </tr>
         </table>
         </td>
         <td rowspan="3" valign="top">
         <cfoutput query="getsugobs">
         <cfif id eq url.keyword>
              <textarea name="traitdescription" cols="75" rows="8" disabled><cfif url.trait eq 1>
#trim(postrait)#<cfelse>#trim(negtrait)#</textarea>                      
         </cfif>
         </cfoutput>          
         </td>
      </tr>
</form>

</BODY>
</HTML>

Regards
Hart
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
Lease-to-own eliminates the expenditure of hardware replacement and allows you to pay off the server over time. Usually, this is much cheaper than leasing servers. Think of lease-to-own as credit without interest.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

860 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