I want someone to be able to mark off a task and have it timestamped and remain un-editable.
How would I use a checkbox and submit button in html or php to make the text following bold and timestamped?
That is actually pretty complicated.
Basically, give the checkbox a value like value='box1checked' and name it something like name='checkbox1'
Then, have the submit button reload the page.
The $_POST['checkbox1'] will have the value 'box1checked' or it could be an empty variable.
Now, within your html, embed the following:
%26lt;?php if ($_POST['checkbox1'] == 'box1checked') echo html to highlight text. ?%26gt;
Hey, if you can't figure this out, send me an EMail and I will whip an example up for you when I get home tonight.
***Your gonna need to implement MySQL to save any permanent data. that is a whole'nother story.
Reply:%26lt;?
if(isset($_POST['submit_form']) {
$time = time();
}
echo "text - %26lt;b%26gt;$time%26lt;/b%26gt;";
?%26gt;
Didn't catch your update. If you want to save this information you'll need a database and need to do a query as such.
%26lt;?
if(isset($_POST['submit_form']) {
$time = time();
$u = mysql_query("UPDATE table SET time='$time' WHERE task_id='".$_GET['id']."'") or die("error! ".mysql_error());
}
?%26gt;
Reply:do you want this to happen automatically on the page, or have an update in the database?
If you want it to happen in the page itself, without going back, updating the db, and requesting a new page you need to use javascript like:
%26lt;input type = "checkbox" onclick = "document. getElementById( 'mySpan' ). style+= 'font-weight: bold';"%26gt; %26lt;span id="myspan"%26gt;text to bold later%26lt;/span%26gt;
If you want the back end to control it, just use php to set a timestamp in the db related to that task (depends on how you have the database set up) and if that field is filled on a request surround the copy with a %26lt;strong%26gt; tag.
To disable a text field in html just include 'disabled = "disabled"' in the %26lt;input%26gt; tag.
You can make it do both, or just turn the act of clicking the checkbox into a submit by adding onclick = "this.form.submit()" to the checkbox input tag. It will then go back to the back end, updated the db, and request the page like I described.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment