[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[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!

6.4

Using onChange with CakePHP

Asked by barnent1 in PHP Frameworks, PHP Scripting Language

Tags: PHP CakePHP Frameworks onChange Change Elements by Select

Dear Experts,

I have a good one today. I have a view in cakephp in which has several dropdown list boxes.

FreqType which has H = Hour, D = Day and N = Now

The desired result is when someone selects from the FreqType listbox. It determines if one of the other other listboxes show.

The problem is that the onchange event is not firing. If I code the ddlistbox in regular html with out using the cake functions it works. Here is the current code

Oddly the view source shows the correct HTML.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
javascript - if I can get the code to just fire the alert I have defined I would be happy.
 
<script language="javascript">
function showFields(){    
    var selected = document.getElementById('freq_type').value
         alert(selected);
    // Hide all fields we show/hide just to be sure we don't show the wrong ones.
    document.getElementById('div_freq').style.display="block"
    document.getElementById('d').style.display="none"
    document.getElementById('e').style.display="none"
 
    if(selBox.selectedIndex==0){
    // Show the fields we want to show if the first option is selected.
        document.getElementById('c').style.display="block"
    }else{
    // Extend with more else..if-statements or use a switch-statement......
    }
}
</script>
 
CakePHP view  code
 
<div class="rssfeeds_form"> 
<?php echo $form->create('Tweetlater');?>
    <fieldset>
         <legend class="legend_add_rssfeeds"><?php __('Add a Scheduled Tweet');?></legend>
    <?php
        echo $form->input('userid', array('type' => 'hidden', 'value' => $UserID));
        echo $form->input('name', array('label' => 'Description: ', 'size' => '30')); 
        $options_postto=array('T'=>'Twitter','P'=>'PingFM');
        echo "Post To: ".$form->select('postto',$options_postto,'T');
        echo " ";
        $options_freq_type=array('H'=>'Hour','D'=>'Day','N'=>'Now');
        echo "Frequency Type: ".$form->select('freq_type',$options_freq_type,'H', array('onChange'=>'showFields(this)'));        
        echo " ";        
        $options_freq=array('1'=>'Every Hour','2'=>'Every 2 Hours','3'=>'Every 3 Hours','6'=>'Every 6 Hours','8'=>'Every 8 Hours','12'=>'Every 12 Hours');
        echo "Frequency: ".$form->select('freq',$options_freq,'1', array('showEmpty'=>'false'));
        echo " ";
        $options_num_posts = array('0'=>'0','1'=>'1', '2'=>'2', '3'=>'3', '4'=>'4', '5'=>'5');
        echo "Number of Posts: ".$form->select('numposts',$options_num_posts,'0');
        echo "<br />";
    ?>
    </fieldset>
<center><?php echo $form->end('Submit'); ?></center>
</div>
[+][-]10/26/09 05:01 PM, ID: 25668210Accepted Solution

View this solution now by starting your 30-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

Zones: PHP Frameworks, PHP Scripting Language
Tags: PHP CakePHP Frameworks onChange Change Elements by Select
Sign Up Now!
Solution Provided By: barnent1
Participating Experts: 0
Solution Grade: A
 
 
Loading Advertisement...
20091021-EE-VQP-81 - Hierarchy / EE_QW_3_20080625