Retourweb: CSS - Java - JavaScript
2008-01-22 14:50:37 (ID: 37, Parent: 33, Type: page)
Java and JavaScript receipes and documentation
Documentation
Download
Java environnement
http://www.java.com/en/download/manual.jsp
How to open a search windows and return result in a form Function to open the window
<
a href=
"#" onClick=
"open_window_recherche(usager.sta_id,'recherche_usager.php');" class=
"normal">Rechercher</
a>
Function to return the value
function selection_usager()
{
var sta_id = document.recherche.sta_id.value;
if(sta_id == -1)
{
alert('Vous devez sélectionner un usager dans la liste !');
}
else
{
window.opener.location.href = "config_utilisateurs.php?sta_id="+sta_id;
this.close();
}
}// fin function selection_usager
How to move items from a list into another code snippet
function add_institution()
{
var index = document.usager.inst_disponible.selectedIndex;
if(index != -1)
{
if(document.usager.inst_disponible.options[index].value != -1)
{
var temp = new Option(document.usager.inst_disponible.options[index].text, document.usager.inst_disponible.options[index].value, false, false);
document.usager.inst_usager.options[document.usager.inst_usager.length] = temp;
document.usager.inst_disponible.remove(document.usager.inst_disponible.selectedIndex);
}
}
}// fin add_institution()
function sub_institution()
{
var index = document.usager.inst_usager.selectedIndex;
if(index != -1)
{
if(document.usager.inst_usager.options[index].value != -1)
{
var temp = new Option(document.usager.inst_usager.options[index].text, document.usager.inst_usager.options[index].value, false, false);
document.usager.inst_disponible.options[document.usager.inst_disponible.length] = temp;
document.usager.inst_usager.remove(document.usager.inst_usager.selectedIndex);
}
}
}//fin sub_institution
The function could be called within any object that support < onclick="" > property.
Html code look like this:
<
select name=
"inst_usager" size=
"8" >
<
option value=
"-1">Centres de l'usager</
option>
</
select>
<
img src=
"images/puce_gauche.gif" onClick=
"add_institution()" >
<
img src=
"images/puce_droite.gif" onClick=
"sub_institution()" >
<
select name=
"inst_disponible" size=
"8" >
<
option value=
"-1">Centres disponible</
option>
<
option value=
"546321" >Centre hospitalier #1</
option>
<
option value=
"987654" >Centre hospitalier #2</
option>
<
option value=
"987658" >Centre hospitalier #3</
option>
<
option value=
"888888" >Centre hospitalier #4</
option>
<
option value=
"123654" >Centre hospitalier #5</
option>
</
select>
Using session parameters (to validate login)
Here are an example