-
problema get con php
Ciao a tutti, oggi stavo modificando la pagina del mio sito applicando vari script.
Tra cui uno particolare modificanto da un amico che permette al click di far alzare un contenuto in alto rispetto alla scritta di lancio della slide. Il mio problema però e che non reisco a impostare cosa voglio che ci sia dentro lo spazio che "si alza" sotto forma di slide. La mia idea era quella di creare una pagina php che richiamasse ogni link per dargli una destinazione con il case e break ma non riesco. Ora vi posto cosa sono riuscito a fare:
Ecco il codice html:
Codice:
<a href="#" ref="php" id="impariamophp" title="|Una delle tante guide in php">
<span class="test">
<span class="livelloup"><span class="textlabel">Livello di up </span>30%</span>
</span>
</a>
e php
Codice:
<?php
$_GET['#'] = $lavori;
switch ($lavori) {
case 'php' :
echo "Oggi impariamo il php";
break;
}
?>
e il codice js:
Codice:
function caricaslide(type)
{
$.post(
"./prova.php",
{ type: type},
function(data){
$("#detail").html(data);
$("#techDetailLoading").hide();
$("input[type='text']:first", document.forms["form"]).focus();
initCluetip();
}
);
}
Probabilmente ho sbagliato il codice php usando il case che non ci vuole ma non riuscivo a trovare altra soluzione.
-
devi definire una variabile nel query string es.:
Codice HTML:
<a href="prova.php?ref=php">
che poi vai a prendere con $_GET['ref'] es.:
Codice PHP:
if (isset($_GET['ref'])) $lavori = $_GET['ref'];
-
Codice:
<a href="prova.php?ref=php">
è da mettere nell'html o nel comandi javascript? Perchè se lo metto nell'html non va devo lasciare per forza # per io voglio la slide nlela stessa pagina del link stesso.
Nel php invece posso usare sempre i case? In questo modo?:
Codice:
case $lavori==php :
echo "ciao";
break;
-
il cancelletto # in php non definisce nulla, è come scrivere:
Codice HTML:
<a href="javascript:void(0);">
perchè $_GET funzioni devi definire una variabile nel query string....
una volta definita la variabile $lavori, puoi gestire come meglio credi questa variabile, case compreso.....
non ho capito bene come lanci la funzione javascript per lo slide...
potresti fare che lanciare la funzione slide ogni volta che viene cliccato il link, aggiungendo l'evento onclick, e aggiungendo la variabile interessata, e modificando quindi la funzione :
Codice HTML:
<a href="javascript:void(0);" onclick="caricaslide(type, 'php');" id="impariamophp" title="|Una delle tante guide in php">
nella funzione caricaslide:
Codice HTML:
<script language="JavaScript" type="text/javascript">
function caricaslide(type, ref)
{
$.post(
"./prova.php?ref="+ref+"",
{ type: type},
function(data){
$("#detail").html(data);
$("#techDetailLoading").hide();
$("input[type='text']:first", document.forms["form"]).focus();
initCluetip();
}
);
}
</script>
però ripeto non so come richiami questa funzione......
devi provare....
-
ciao grazie dell'aiuto. Come ho scritto questi codici non gli ho fatti io ma me gli ha dati un amico in real. Oggi gli ho chiesto dove ha preso quei codici per permettermi di adattarli al mio sito e mi ha riposto che gli ha presi da ogame. Guardando bene in effetti i codici combaciano. Inoltre gli ho chiesto se sapeva adattarli al mio sito ma ha detto che c'è da riscrrivere tutto il js.
-
qui trovi DYNAMIC CONTENT per addattarlo alle tue esigenze....dai una occhiata:
è gratuito e ben spiegato:
http://www.dynamicdrive.com/dynamicindex17/index.html
-
ciao lo finalmente trovata.
Solo due cosette:
- come faccio a fare modificare la slide in alto?
- come posso fare in modo che nella pagina ci sia un immagine e quando clicco su mostra per far partire la slide il nuovo box si trovi sopra l'immagine?
-
scusami, che cosa hai trovato?
a cosa ti riferisci....? a quale codice voglio dire?
-
Allora io ho trovato questo:
parte html:
Codice:
<!DOCTYPE HTML>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" src="animatedcollapse.js">
/***********************************************
* Animated Collapsible DIV v2.4- (c) Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for this script and 100s more
***********************************************/
</script>
<script type="text/javascript">
animatedcollapse.addDiv('jason', 'fade=1,height=80px')
animatedcollapse.addDiv('kelly', 'fade=1,height=100px')
animatedcollapse.addDiv('michael', 'fade=1,height=120px')
animatedcollapse.addDiv('cat', 'fade=0,speed=400,group=pets')
animatedcollapse.addDiv('dog', 'fade=0,speed=400,group=pets,persist=1,hide=1')
animatedcollapse.addDiv('rabbit', 'fade=0,speed=400,group=pets,hide=1')
animatedcollapse.ontoggle=function($, divobj, state){ //fires each time a DIV is expanded/contracted
//$: Access to jQuery
//divobj: DOM reference to DIV being expanded/ collapsed. Use "divobj.id" to get its ID
//state: "block" or "none", depending on state
}
animatedcollapse.init()
</script>
</head>
<body>
<a href="javascript:animatedcollapse.toggle('jason')">Toggle Display</a> | <a href="javascript:animatedcollapse.show('jason')">Slide Down</a> | <a href="javascript:animatedcollapse.hide('jason')">Slide Up</a>
<div id="jason" style="width: 300px; background: #FFFFCC; display:none">
<b>Content inside DIV!</b><br />
<b>Note: Fade effect enabled. Height programmically defined. DIV hidden using inline CSS.</b><br />
</div>
</body>
-
e javascript (scusate il doppio post ma non ci sta altrimenti)
Codice:
var animatedcollapse={
divholders: {},
divgroups: {},
lastactiveingroup: {},
preloadimages: [],
show:function(divids){
if (typeof divids=="object"){
for (var i=0; i<divids.length; i++)
this.showhide(divids[i], "show")
}
else
this.showhide(divids, "show")
},
hide:function(divids){
if (typeof divids=="object"){
for (var i=0; i<divids.length; i++)
this.showhide(divids[i], "hide")
}
else
this.showhide(divids, "hide")
},
toggle:function(divid){
if (typeof divid=="object")
divid=divid[0]
this.showhide(divid, "toggle")
},
addDiv:function(divid, attrstring){
this.divholders[divid]=({id: divid, $divref: null, attrs: attrstring})
this.divholders[divid].getAttr=function(name){
var attr=new RegExp(name+"=([^,]+)", "i")
return (attr.test(this.attrs) && parseInt(RegExp.$1)!=0)? RegExp.$1 : null
}
this.currentid=divid
return this
},
showhide:function(divid, action){
var $divref=this.divholders[divid].$divref
if (this.divholders[divid] && $divref.length==1){
var targetgroup=this.divgroups[$divref.attr('groupname')]
if ($divref.attr('groupname') && targetgroup.count>1 && (action=="show" || action=="toggle" && $divref.css('display')=='none')){
if (targetgroup.lastactivedivid && targetgroup.lastactivedivid!=divid)
this.slideengine(targetgroup.lastactivedivid, 'hide')
this.slideengine(divid, 'show')
targetgroup.lastactivedivid=divid
}
else{
this.slideengine(divid, action)
}
}
},
slideengine:function(divid, action){
var $divref=this.divholders[divid].$divref
var $togglerimage=this.divholders[divid].$togglerimage
if (this.divholders[divid] && $divref.length==1){
var animateSetting={height: action}
if ($divref.attr('fade'))
animateSetting.opacity=action
$divref.animate(animateSetting, $divref.attr('speed')? parseInt($divref.attr('speed')) : 500, function(){
if ($togglerimage){
$togglerimage.attr('src', ($divref.css('display')=="none")? $togglerimage.data('srcs').closed : $togglerimage.data('srcs').open)
}
if (animatedcollapse.ontoggle){
try{
animatedcollapse.ontoggle(jQuery, $divref.get(0), $divref.css('display'))
}
catch(e){
alert("An error exists inside your \"ontoggle\" function:\n\n"+e+"\n\nAborting execution of function.")
}
}
})
return false
}
},
generatemap:function(){
var map={}
for (var i=0; i<arguments.length; i++){
if (arguments[i][1]!=null){
map[arguments[i][0]]=arguments[i][1]
}
}
return map
},
init:function(){
var ac=this
jQuery(document).ready(function($){
animatedcollapse.ontoggle=animatedcollapse.ontoggle || null
var urlparamopenids=animatedcollapse.urlparamselect()
var persistopenids=ac.getCookie('acopendivids')
var groupswithpersist=ac.getCookie('acgroupswithpersist')
if (persistopenids!=null)
persistopenids=(persistopenids=='nada')? [] : persistopenids.split(',')
groupswithpersist=(groupswithpersist==null || groupswithpersist=='nada')? [] : groupswithpersist.split(',')
jQuery.each(ac.divholders, function(){
this.$divref=$('#'+this.id)
if ((this.getAttr('persist') || jQuery.inArray(this.getAttr('group'), groupswithpersist)!=-1) && persistopenids!=null){
var cssdisplay=(jQuery.inArray(this.id, persistopenids)!=-1)? 'block' : 'none'
}
else{
var cssdisplay=this.getAttr('hide')? 'none' : null
}
if (urlparamopenids[0]=="all" || jQuery.inArray(this.id, urlparamopenids)!=-1){
cssdisplay='block'
}
else if (urlparamopenids[0]=="none"){
cssdisplay='none'
}
this.$divref.css(ac.generatemap(['height', this.getAttr('height')], ['display', cssdisplay]))
this.$divref.attr(ac.generatemap(['groupname', this.getAttr('group')], ['fade', this.getAttr('fade')], ['speed', this.getAttr('speed')]))
if (this.getAttr('group')){ //if this DIV has the "group" attr defined
var targetgroup=ac.divgroups[this.getAttr('group')] || (ac.divgroups[this.getAttr('group')]={}) //Get settings for this group, or if it no settings exist yet, create blank object to store them in
targetgroup.count=(targetgroup.count||0)+1 //count # of DIVs within this group
if (jQuery.inArray(this.id, urlparamopenids)!=-1){ //if url parameter string contains this div's ID
targetgroup.lastactivedivid=this.id //remember this DIV as the last "active" DIV (this DIV will be expanded). Overrides other settings
targetgroup.overridepersist=1 //Indicate to override persisted div that would have been expanded
}
if (!targetgroup.lastactivedivid && this.$divref.css('display')!='none' || cssdisplay=="block" && typeof targetgroup.overridepersist=="undefined") //if this DIV was open by default or should be open due to persistence
targetgroup.lastactivedivid=this.id //remember this DIV as the last "active" DIV (this DIV will be expanded)
this.$divref.css({display:'none'}) //hide any DIV that's part of said group for now
}
}) //end divholders.each
jQuery.each(ac.divgroups, function(){ //loop through each group
if (this.lastactivedivid && urlparamopenids[0]!="none") //show last "active" DIV within each group (one that should be expanded), unless url param="none"
ac.divholders[this.lastactivedivid].$divref.show()
})
if (animatedcollapse.ontoggle){
jQuery.each(ac.divholders, function(){ //loop through each collapsible DIV object and fire ontoggle event
animatedcollapse.ontoggle(jQuery, this.$divref.get(0), this.$divref.css('display'))
})
}
//Parse page for links containing rel attribute
var $allcontrols=$('a[rel]').filter('[rel^="collapse["], [rel^="expand["], [rel^="toggle["]') //get all elements on page with rel="collapse[]", "expand[]" and "toggle[]"
$allcontrols.each(function(){ //loop though each control link
this._divids=this.getAttribute('rel').replace(/(^\w+)|(\s+)/g, "").replace(/[\[\]']/g, "") //cache value 'div1,div2,etc' within identifier[div1,div2,etc]
if (this.getElementsByTagName('img').length==1 && ac.divholders[this._divids]){ //if control is an image link that toggles a single DIV (must be one to one to update status image)
animatedcollapse.preloadimage(this.getAttribute('data-openimage'), this.getAttribute('data-closedimage')) //preload control images (if defined)
$togglerimage=$(this).find('img').eq(0).data('srcs', {open:this.getAttribute('data-openimage'), closed:this.getAttribute('data-closedimage')}) //remember open and closed images' paths
ac.divholders[this._divids].$togglerimage=$(this).find('img').eq(0) //save reference to toggler image (to be updated inside slideengine()
ac.divholders[this._divids].$togglerimage.attr('src', (ac.divholders[this._divids].$divref.css('display')=="none")? $togglerimage.data('srcs').closed : $togglerimage.data('srcs').open)
}
$(this).click(function(){ //assign click behavior to each control link
var relattr=this.getAttribute('rel')
var divids=(this._divids=="")? [] : this._divids.split(',') //convert 'div1,div2,etc' to array
if (divids.length>0){
animatedcollapse[/expand/i.test(relattr)? 'show' : /collapse/i.test(relattr)? 'hide' : 'toggle'](divids) //call corresponding public function
return false
}
}) //end control.click
})// end control.each
$(window).bind('unload', function(){
ac.uninit()
})
}) //end doc.ready()
},
uninit:function(){
var opendivids='', groupswithpersist=''
jQuery.each(this.divholders, function(){
if (this.$divref.css('display')!='none'){
opendivids+=this.id+',' //store ids of DIVs that are expanded when page unloads: 'div1,div2,etc'
}
if (this.getAttr('group') && this.getAttr('persist'))
groupswithpersist+=this.getAttr('group')+',' //store groups with which at least one DIV has persistance enabled: 'group1,group2,etc'
})
opendivids=(opendivids=='')? 'nada' : opendivids.replace(/,$/, '')
groupswithpersist=(groupswithpersist=='')? 'nada' : groupswithpersist.replace(/,$/, '')
this.setCookie('acopendivids', opendivids)
this.setCookie('acgroupswithpersist', groupswithpersist)
},
getCookie:function(Name){
var re=new RegExp(Name+"=[^;]*", "i"); //construct RE to search for target name/value pair
if (document.cookie.match(re)) //if cookie found
return document.cookie.match(re)[0].split("=")[1] //return its value
return null
},
setCookie:function(name, value, days){
if (typeof days!="undefined"){ //if set persistent cookie
var expireDate = new Date()
expireDate.setDate(expireDate.getDate()+days)
document.cookie = name+"="+value+"; path=/; expires="+expireDate.toGMTString()
}
else //else if this is a session only cookie
document.cookie = name+"="+value+"; path=/"
},
urlparamselect:function(){
window.location.search.match(/expanddiv=([\w\-_,]+)/i) //search for expanddiv=divid or divid1,divid2,etc
return (RegExp.$1!="")? RegExp.$1.split(",") : []
},
preloadimage:function(){
var preloadimages=this.preloadimages
for (var i=0; i<arguments.length; i++){
if (arguments[i] && arguments[i].length>0){
preloadimages[preloadimages.length]=new Image()
preloadimages[preloadimages.length-1].src=arguments[i]
}
}
}
}
-
il codice che hai scritto fa riferimento a questo codice js a questa pagina:
http://www.dynamicdrive.com/dynamici...edcollapse.htm
ora non ho capito bene quali modifiche vuoi apportare al codice, comunque il codice si divide in 2 parti....una è nell'head e l'altra nel body.
quella nel body ti permette di inserire quello che vuoi far visualizzare nella tua pagina...il contenuto è in ogni
Codice HTML:
<div id="" style=""> qui inserisci il tuo contenuto anche immagini </div>
....ora modificando lo stile modifichi quello che vuoi del div, il background, la dimensione, ecc....
-
Allora vorrei capire solo questa cosa:
- Come modifico la direzione della slide? attualmente è dall'alto verso il basso e io vorrei fare il contrario
-
ho provato a verificare la possibilità di modificare il js come vorresti tu, in effetti ho apportato alcune modifiche o comunque ho provato ma non ci sono riuscito.....sorry!
posso consigliarti di contattare dynamicdrive e chiedere se possibile effettuare tale modifica....
puoi contattarli sul forum: http://www.dynamicdrive.com/forums/
ciao....
-
ci sono riuscito bastava cambiare l'ordine dei div e mettere prima il contentuto della slide e poi il comando che la apre e chiude