使用php在js函数中传递值

时间:2015-01-07 03:57:19

标签: javascript php jquery

这是我在网上找到的用于显示抄表的javascript代码。

<script type="text/javascript"    src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js"></script>
    <!-- Wijmo CSS and script -->
    <link type="text/css" href="http://cdn.wijmo.com/themes/aristo/jquery-wijmo.css" rel="stylesheet" title="metro-jqueryui" />
    <link type="text/css" href="http://cdn.wijmo.com/jquery.wijmo-complete.all.2.1.0.min.css" rel="stylesheet" />
    <script type="text/javascript" src="http://cdn.wijmo.com/jquery.wijmo-open.all.2.1.0.min.js"></script>
    <script type="text/javascript" src="http://cdn.wijmo.com/jquery.wijmo-complete.all.2.1.0.min.js"></script>
    <!-- KnockoutJS for MVVM-->
    <script type="text/javascript" src="http://cdn.wijmo.com/external/knockout-2.0.0.js"></script>
    <script type="text/javascript" src="http://cdn.wijmo.com/external/knockout.wijmo.js"></script>

这是他们的功能

 <script type="text/javascript">
<!-- when document loads, create ViewModel, and apply bindings-->
<!-- Create ViewModel-->
    var viewModel = function () {
        var self = this;
        self.val = ko.observable(50);
        self.min = ko.observable(0);
        self.max = ko.observable(100);
    };

<!-- Bind ViewModel-->
    $(document).ready(function () {
        var vm = new viewModel();
        ko.applyBindings(vm);
    });
</script>



<div class="container"> 
    <div class="header"> 
        <h2> 
            Overview</h2> 
    </div> 
    <div class="main demo"> 
        <!-- Begin demo markup -->
        <p> 
        </p> 

我想通过使用php隐藏输入类型来从这里传递值。

        <div data-bind="wijslider: {value: val}" style="width: 600px;"> 
        </div> 

因为我有一些$_post生成的值。我尝试了很多,但无法通过一个!帮助

1 个答案:

答案 0 :(得分:0)

<?if(!$_post) { ?>
    <!-- html --!>
<?else { ?>
    <!-- html --!>
<?} ?>

您还可以看到[1]:http://php.net/manual/en/control-structures.alternative-syntax.php