PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of Rafael Rend   Rend Double Select   example.php   Download  
File: example.php
Role: Auxiliary script
Content type: text/plain
Description: Example of use
Class: Rend Double Select
Select multiple form values using 2 select inputs
Author: By
Last change: change word "from" by word "of" in titles.
Date: 12 years ago
Size: 4,079 bytes
 

Contents

Class file image Download
<?
//Author: Rafael Rend - rafaelrend@gmail.com -> Creation Date-> 2012-11-10 Year: 2012, Month: 11, Day: 10
//Site: http://www.rendti.com.br, http://rafaelrend.wordpress.com/

    //4 Steps.
    // 1) Include the RendDoubleSelect.php
    // 2) Include the javascript file selectbox.js
    // 3) Use tag <form
    // 4) Inside <form, Call method RendDoubleSelect::showDoubleDropDown

   
require_once("RendDoubleSelect.php");
   

?>
<html>
<head>
<title>Double Select Example</title>
<script src="selectbox.js" type="text/javascript"></script>
</head>
<body>
<form method="post" name="frm" >
<h1>1) Double Select without optgroup </h1>
<h2>Data: Cities of Brasil</h2>
<?
 
//Example array of data.
 
$data = array();
 
$data[ count($data) ] = array("id"=>"1","name"=>"Aracajú");
 
$data[ count($data) ] = array("id"=>"2","name"=>"Belo Horizonte");
 
$data[ count($data) ] = array("id"=>"3","name"=>"Recife");
 
$data[ count($data) ] = array("id"=>"4","name"=>"Salvador");
 
$data[ count($data) ] = array("id"=>"5","name"=>"São Paulo");
 
 
$data_selected = array(); //Second array of data, if you want, on load page, show data in right's select.

  //Step 4. Read about this method at file RendDoubleSelect.php
 
RendDoubleSelect::showDoubleDropDown($data, $data_selected, "id", "name", "",
      
"sel_cities1", "sel_cities2", "hd_cities", "130px",
      
"Avaliable", "Selected");

?>
- EN: <i>Beyond Buttons, also you can use double click, in wanted value, to transfer between select</i><br>
 - PT: <i>Além dos botões, você também pode dar um duplo clique no valor desejado </i>
 
  <br>
 <input type="button" name="btVal1" value="Show Selected Values" onclick="alert( getValuesFromSelect(document.getElementById('sel_cities2')) )" >
 <br><br>
 
 <h1>2) Double Select with optgroup </h1>
<h2>Data: Cities of Brasil grouped by state</h2>
<?
 
//Example array of data.
 
$data = array();
 
$data[ count($data) ] = array("id"=>"1","name"=>"Aracajú","state"=>"Sergipe");
 
$data[ count($data) ] = array("id"=>"2","name"=>"Lagarto","state"=>"Sergipe");
 
$data[ count($data) ] = array("id"=>"3","name"=>"Estancia","state"=>"Sergipe");
 
 
$data[ count($data) ] = array("id"=>"4","name"=>"Belo Horizonte","state"=>"Minas Gerais");
 
$data[ count($data) ] = array("id"=>"5","name"=>"Patos de Minas","state"=>"Minas Gerais");
 
$data[ count($data) ] = array("id"=>"6","name"=>"Uberlândia","state"=>"Minas Gerais");
 
$data[ count($data) ] = array("id"=>"7","name"=>"Uberaba","state"=>"Minas Gerais");

 
 
$data[ count($data) ] = array("id"=>"8","name"=>"Salvador","state"=>"Bahia");
 
$data[ count($data) ] = array("id"=>"9","name"=>"Camaçarí","state"=>"Bahia");
 
$data[ count($data) ] = array("id"=>"10","name"=>"Lauro de Freitas","state"=>"Bahia");
 
$data[ count($data) ] = array("id"=>"11","name"=>"Itabuna","state"=>"Bahia");
 
 
$data_selected = array(); //Second array of data, if you want, on load page, show data in right's select.

  //Step 4. Read about this method at file RendDoubleSelect.php
 
RendDoubleSelect::showDoubleDropDown($data, $data_selected, "id", "name", "state",
      
"sel_cities_opt1", "sel_cities_opt2", "hd_cities_opt", "160px",
      
"Avaliable", "Selected");

?>
- EN: <i>Presh "shift", to select more than 1 value</i><br>
 - PT: <i>Pressione "shift" para selecionar mais de um valor </i>
 
 <br>
 <input type="button" name="btVal2" value="Show Selected Values" onclick="alert( getValuesFromSelect(document.getElementById('sel_cities_opt2')) )" >
  <br><br>
</form>

Author: Rafael Rend - rafaelrend@gmail.com - http://www.rendti.com.br, http://rafaelrend.wordpress.com/
<br><br>
EN: This example also can be downloaded at url:
<a href="http://www.rendti.com.br/examples/renddoubleselect.rar" target="_blank">
www.rendti.com.br/examples/renddoubleselect.rar</a>

<br><br>
PT: Você também pode fazer o download através desta url:
<a href="http://www.rendti.com.br/examples/renddoubleselect.rar" target="_blank">
www.rendti.com.br/examples/renddoubleselect.rar</a>

</body>
</html>