buondì,
sono nuovissimo di javascript, ciò che vorrei è avere una lista di nomi, facendo click su ognuno, sotto al nome dovrebbe aprirsi un div nel quale venga caricata una pagina php.
Credo sia una cosa semplice per voi che ne sapete, per me purtroppo è un po' arabo..
ciò che ho appezzato finora è (con jQuery);
codice:
var state = 'none';
function show(show_id)
{
var ss= document.getElementById(show_id);
var len= ss.options.length;
var str="";
var j=0;
for(var i=0;i<len;i++){
if(ss.options[i].selected == true)
{
if(j == 0)
str= ss.options[i].value;
else
str += '|' + ss.options[i].value;
j++;
}
}
return str;
}
function showhide(id, page, form, append, data) {
if (state == 'block') {
state = 'none';
}
else {
state = 'block';
var veri = '';
if( typeof(data) == "string")
veri = data;
else
veri = $(form).serialize();
$.ajax({
type: "POST",
url: page,
data: veri,
error: function(html)
{
alert("Errore..");
},
success: function(html)
{
if( typeof(append) == "boolean")
$(id).append(html);
else
$(id).html(html);
}
});
}
if (document.all) { //IS IE 4 or 5 (or 6 beta)
eval( "document.all." + id + ".style.display = state");
}
if (document.layers) { //IS NETSCAPE 4 or below
document.layers[id].display = state;
}
if (document.getElementById &&!document.all) {
hza = document.getElementById(id);
hza.style.display = state;
}
}
richiamato poi nella pagina con:
Codice PHP:
<div style="width:100%; vertical-align:middle; border:1px solid #09C; background-color:#CCC; cursor:pointer;" >
<div id="test<?php echo $customers['customer_id'] ?>" onClick="showhide('#responso<?php echo $customers['customer_id'] ?>', 'customers_details.php', form_<?php echo $customers['customer_id'] ?>, null, null);"><?php echo $customers['customers_name']; ?>
<form id="form_<?php echo $customers['customer_id'] ?>">
<input type="hidden" name="customer_id" value="<?php echo $customers['customer_id'] ?>">
</form>
</div>
<div style="display: none;" id="responso<?php echo $customers['customer_id'] ?>"></div>
</div>
quello che mi serve è passare un unico dato al mio file php: il $customers['customer_id'], io ho trovato come farlo con un form, ma se ci fosse un qualunque altro modo che mi eviti righe di codice inutili tanto meglio!
Grazie!