Reputation: 73
Hi i use this PHP script http://www.stevedawson.com/scripts/text-counter.php
And to make it appear on my html page i use this ajax script.
<script>
$.ajax({
type:'GET',
url:'http://www.solariserat.se/count.php',
data:'',
success: function(data){
$('#container').html(data);
}
});
</script>
Together with this html code
<div id="container">
<?php include "count.php"; ?>
</div>
And it works perfect and it displays the counted numbers inside the div.
But i want it to be displayed as value inside a input tag Is this possible, and how do i do it?
I know this is wrong but you get my point what i want to do =)
<input value="count.php">
Upvotes: 1
Views: 606
Reputation: 73
I manage to get the values inside a input field so i can now send it with a form and submit button.
Maybe it's not a good locking solution, but it works.
I made an iframe that shows a .php page and made a input field like this
<input value="<?php include "count.php"; ?>">
And then i made a script placed in parent .html page like this
function boahaga() {
var myphp = window.frames["invoice"].document.getElementById ( "myidbo" ).value,
result = document.getElementById('fakturanr_from'),
myResult;
{
myResult = myphp;
result.value = (myResult);
}
}
And inside the body tag i run script onload.
<body onload="boahaga()">
Now the input on the parent .html page is filled correct with the .php page input value.
Upvotes: 0
Reputation: 11859
you should be using php tag for this :
<input value="<?php include "count.php"; ?>">
i'll suggest do not use short tags until and unless you are handling them properly.
if you want to show some value use:
<input value="<?php echo $count; ?>">// here count is a variable.
Upvotes: 0
Reputation: 30416
This should work:
<input value="<?php include "count.php"; ?>">
However a cleaner approach would be to include the count value in the PHP page that is rendering the <input>
so you can do something like this:
<input value="<?= count ?>">
Upvotes: 3