输入字段的 PHP 计数器


PHP counter to input field

嗨,我使用这个PHP脚本 http://www.stevedawson.com/scripts/text-counter.php

为了使它出现在我的html页面上,我使用了这个ajax脚本。

<script>
$.ajax({
    type:'GET',
    url:'http://www.solariserat.se/count.php',
    data:'',
    success: function(data){
            $('#container').html(data);
    }
});
</script>

连同这个 html 代码

<div id="container">    
<?php include "count.php"; ?>
</div>

它工作得很好,它在div 内显示计数的数字。

但我希望它在输入标签中显示为值这可能吗,我该怎么做?

我知道这是错误的,但你明白我的意思我想做什么=)

<input value="count.php">

这应该有效:

<input value="<?php include "count.php"; ?>">

但是,更干净的方法是在呈现<input>的 PHP 页面中包含计数值,以便您可以执行以下操作:

<input value="<?= count ?>">

你应该为此使用 php 标签:

<input value="<?php include "count.php"; ?>">

我建议不要使用短标签,除非你处理得当。

如果要显示一些值,请使用:

<input value="<?php echo $count; ?>">// here count is a variable.

我设法在输入字段中获取值,因此我现在可以使用表单和提交按钮发送它。

也许这不是一个好的锁定解决方案,但它有效。

我制作了一个显示.php页面的 iframe,并制作了一个这样的输入字段

<input value="<?php include "count.php"; ?>">

然后我做了一个脚本放在父.html页面,像这样

 function boahaga()  {
    var myphp = window.frames["invoice"].document.getElementById ( "myidbo" ).value, 
        result = document.getElementById('fakturanr_from'),
        myResult;
    {
      myResult = myphp;
      result.value = (myResult);
    }

}

在正文标签中,我运行脚本加载。

<body onload="boahaga()">

现在,父.html页面上的输入已正确填充.php页面输入值。