Solved

Need help with javascript

Posted on 2004-03-24
10
152 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
Comment Utility
who do you want the radio and selectbox to work together?
0
 

Author Comment

by:swartout
Comment Utility
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
Comment Utility
can you post the compiled code?
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

Author Comment

by:swartout
Comment Utility
<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
Comment Utility
explain a little more in depth about what the select box needs to do
0
 

Author Comment

by:swartout
Comment Utility
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
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

744 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now