다음 코드가 포함 된 스크립트가 있습니다은 자바 스크립트 함수에 전역 변수를 추가
$(function(){
var e=$.cookie("list_grid");
if(e=="g"){
$("#products").addClass("smallGrid");
$("#smallGrid").addClass("disabled")
}else if(e=="l"){
$("#products").addClass("largeGrid");
$("#products").removeClass("smallGrid");
$("#largeGrid").addClass("disabled")
}else{
$("#products").addClass("listGrid");
$("#products").removeClass("largeGrid");
$("#products").removeClass("smallGrid");
$("#list").addClass("disabled")}});
$(function(){
$("#smallGrid").click(function(){
$("#products").fadeOut(300,function(){
$(this).removeClass("listGrid").fadeIn(300);
$(this).addClass("smallGrid").fadeIn(300);
$(this).removeClass("largeGrid").fadeIn(300);
$.cookie("list_grid","g")});
$(this).addClass("disabled");
$("#list").removeClass("disabled");
$("#largeGrid").removeClass("disabled");
return false});
$("#largeGrid").click(function(){
$("#products").fadeOut(300,function(){
$(this).addClass("largeGrid").fadeIn(300);
$(this).removeClass("listGrid").fadeIn(300);
$(this).removeClass("smallGrid").fadeIn(300);
$.cookie("list_grid","l")});
$(this).addClass("disabled");
$("#smallGrid").removeClass("disabled");
$("#list").removeClass("disabled");
return false});
$("#list").click(function(){
$("#products").fadeOut(300,function(){
$(this).addClass("listGrid").fadeIn(300);
$(this).removeClass("smallGrid").fadeIn(300);
$(this).removeClass("largeGrid").fadeIn(300);
$.cookie("list_grid",null)});
$(this).addClass("disabled");
$("#smallGrid").removeClass("disabled");
$("#largeGrid").removeClass("disabled");
return false})
})
내가 어떤에서 사용할 수있는 VAR를 추가 할 필요를 다른 페이지에 PHP 코드. 이 VAR의 목적은 내가 출력은 사용자 요청의 데이터를 참조하는 어떤 형식에 따라 특정 유형을 트리거 할 수 있도록 선택한 어떤 목록 유형을 알고있다.
내가
$("#smallGrid").click(function(){
을 변경하려
는
$("#smallGrid").click(function(){
var listingStyle="small"
같은
과 VAR을 포함하는하지만 난 내 PHP 코드에서 $ listingStyle의 내용을 에코 때 비어 있습니다. 사람이 어떤 제안이있는 경우 이 사이트는 세계 바르 사용할 수 있습니다 그리고 그들은$GLOBALS['variable_name'] = 'this string';
같이 설정하지만 난 PHP를 글로벌 VAR에 자바 스크립트 VAR를 얻을 수있을 것 같지 않습니다
이 될 것이다 대단히 감사드립니다.
은 당신이 HTTP 요청을 사용하여 통신 할 필요가 서버에서 클라이언트 코드에서 뭔가를 설정합니다. AJAX 호출 (선호)을 사용하거나 양식을 제출하십시오. – Johan