design.php
file:
<script>
$(".colr_sldr li img").click(function(){
var src = $(this).attr('src');
var value=src.substring(src.lastIndexOf('/')+1);
<?php $var = "<script>document.write('" + value + "')</script>";?>
});
</script>
and use this variable in index.php
file:
<?php
include('design.php');
echo $var;
?>
here while i am printing this variable it is getting zero can any one help
you can't take var like this in php..
$var = "<script>document.write('" + value + "')</script>";?>
because php is server side language ..
and javascript is client side.
For this you have to use ajax ,get and post methods
the only solution I may know is using jquery on client side an sending your variable via ajax :
script.js
$('document).ready(function(){
var myVar="Hello";
$.post('design.php',myVar);
});
and in design.php you have acces to your variable with $_POST design.php
<?php
$myVar = $_POST['myVar'];
echo $myVar;?>
please check http://api.jquery.com/jQuery.ajax/ for more details