-2
$('#b').bind('click',function(){
                alert('hii');
                var slide_start=slider_content.indexOf(0);
                if(slide_start==2)
                {
                    $('#reg_rem_form').hide();
                }
        var show=1+slide_start;
        var show_first='#'+show;

        **var value_to_insert=<?php  echo $value;?  >=$(show_first).val();**
                <?php

                        /*
                            1. Date of birth
                            2. gender
                            3. Unvi1
                            4. Unvi2
                            5. highest degree unvi1
                            6. highest degree unvi2
                            7. Year of passing unvi1
                            8. Year of passing unvi2
                            9. Current working
                            10. Work experience
                        */


                ?>

就像我们将 php 变量存储在 jquery 变量中一样,但反过来我想将 jquery 变量存储在 php 变量中???突出显示的部分是主线。怎么做,上面的代码给了我错误===缺少“;” 声明之前。

这是正确的方法吗 =$('#bold').val();

4

2 回答 2

1

最简单的方法是使用隐藏元素。

<input type="hidden" name="store" id="store"/>

在 PHP 方面

<input type="hidden" 
   name="store" 
   value="<?php echo htmlspecialchars($variable); ?>">

然后在jquery方面

var jqueryVar = $('#store).val();
于 2012-12-13T06:17:03.560 回答
0

结帐 JSON(JavaScript 对象表示法)

http://php.net/manual/en/book.json.php

将 PHP 数组转换为 javascript

<?php

$php_array = array(0,1,2,3,4,5,6,7,8,9);
$js = "var javascript_array = eval('(' + ".json_encode($php_array)." + ')');

?>
于 2012-12-13T06:38:31.700 回答