Login Retreive lost passwordRegister
Search

Forum Index / General / RadioButton and Javascript

[ This topic is solved ]

  Joao Correa 26 September 08 / 20:11  
Changed at 26 September 08 / 20:13
Hi all,

Is possible to add a javascprit action for each option of radio group?

Example:

<?php

include( "FH3/class.FormHandler.php");

$form = new FormHandler();

$options = array(
  
=> 'Option 1 'JAVASCRIPT,'onClick(Do Something 1);',
  
=> 'Option 2 'JAVASCRIPT,'onClick(Do Something 2);'
);  

$form->radioButton("Test""test"$options);

$form->flush();

?>

  Johan Wiegel (Admin) 26 September 08 / 22:56  
no that's not posible

  Thomas Branius 29 September 08 / 12:36  
Changed at 29 September 08 / 12:44
Hi,

a possible solution:

<?php 

echo <<<END
<script language="javascript" type="text/javascript">
function test(obj)
{
   switch(obj.id) 
{
      case 'test_1' : Do Something 1; break;
      case 'test_2' : Do Something 2; break;
   
}
}
</script>
END;

include( 
"FH3/class.FormHandler.php"); 

$form = new FormHandler(); 

$options = array( 
  
=> 'Option 1'
  
=> 'Option 2' 
);   

$form->radioButton("Test""test"$optionsnulltrue"onClick='test(this)'"); 

$form->flush(); 

?>

  Joao Correa 29 September 08 / 15:10  
Thanks!! work fine!

  Top


powered by PHP-GLOBE   © 2004 - 2009 FormHandler. All rights reserved.   -   Open source license