Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

It′s posible , if i have one var , use jquery for load news vars and change these

For example if i have :

var activate_auto="yes";



$("#play").click(function() {

/// load vars
activate_auto="yes";


});


$("#stop").click(function() {

/// load vars
activate_auto="no";


});

COMPLETE CODE

<script>

var w_ac="900";
var h_ac="295";
var w_ac_col="64";
var n_cols="5";
var margin="3";
var time_ac_change=5000;
var time_ac_effects=2000;
var time_ac_hide_effects=1000;

var ac_activate_auto="si";
var ac_activate_auto_random="no";

var margin=margin*n_cols;
var result=w_ac_col*n_cols+margin;
var final=w_ac-result;


$(function(){




$("#ac_play").click(function() 
{
ac_activate_auto="si";
ac_activate_auto_random="no";
time_ac_change=2000;
});


$("#ac_stop").click(function() 
{
ac_activate_auto="no";
ac_activate_auto_random="no";
time_ac_change=2000000;
});


for (i=1;i<=n_cols;i++)
{

$(".ac_"+i+"").css("width",""+w_ac_col);

}

});


function acordeon(id)
{

$(function(){

for (i=1;i<=n_cols;i++)
{

if (+id==i)
{}
else
{
$(".ac_"+i+"_inf").hide(time_ac_hide_effects);
}

}

$(".ac_"+id+"_inf").css("width",""+final);
$(".ac_"+id+"_inf").show(time_ac_effects).fadeIn(time_ac_effects);

$(".ac_im").css("width",""+final);
$(".ac_im").css("height",""+h_ac);








});





}

</script>


<script>









var starting_slide = n_cols;

function setSlide(i) 
{


acordeon(i);















if (i > 0) {
i--;   
setTimeout( function(){setSlide(i)}, time_ac_change);

}

else 
{
setTimeout( function(){setSlide(starting_slide)}, 1000);
} 

}






if (ac_activate_auto=="si")
{
setSlide(starting_slide);
}






if (ac_activate_auto_random=="si")
{

$(document).ready(function(){

acordeon(1);

var refreshId = setInterval(function(){

var r=Math.floor(Math.random()*n_cols)    

if (r==0)
{
acordeon(1)
}
else
{
acordeon(+r)
}


}, time_ac_change);
});





}

</script>

In this case works always when i push over pay or stop but only one time , if i push over play works play but no works before stop and the same when the first i push it′s play

I want push stop load new var and play and other time load the other var , i don′t know if it′s possible , thank′s !

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
244 views
Welcome To Ask or Share your Answers For Others

1 Answer

You should only create your var and don't set a value to it, and then, only set its values inside your functions. Ex.:

var activate_auto; // this is outside your click functions

Ok, now I'm not sure what you want to do... will edit it later if necessary =


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...