Quote:
Originally Posted by terle
Thanks for answering
I realize now I wasn't very clear in my post as to what I really wanna do.
The goal is to build a simple shopping list.
My gf has an iPhone and myself an Android. On my server I want a website we both can access and see what we need.
On this site I want a list of items (with checkboxes) and a textfield for entering new items.
Somthing like this.
In relation to my question; how do take the new item and add it to the list with a checkbox?
|
to style it for handheld devices remember the media="handheld" or something along that line in your html link to stylesheet
To get values from a form you will need to do either GET or POST the values.
Also the <input> tags MUST BE within the <form> tag aswell which i can see it isnt in the provided link.
Code:
<div class="row">
<form action="editList.php#TabEditList" method="POST">
<label>Input new Item</label>
<div class="six columns">
<input type="text" name="tekstFelt" placeholder="Item Name" />
</div>
<div class="six columns">
<div class="twelve columns">
<input type="checkbox" name="box" value="milk" />Milk<br />
<input type="checkbox" name="box" value="bread" />Bread<br />
<input type="checkbox" name="box" value="butter" />Butter<br />
<input type="submit" href="#" class="tiny round success button"/>
</div>
</form>
</div>
</div>
next thing is to grab the stuff and save them into a database with PHP & SQL which is a scripting language (im only doing it with 2 checkboxes in this example for simplicity) We are grabbing the information send from the form with $_GET / $_POST there is a difference between those and if you wish i can explain the difference but else i wont.. but in this case its best to do it with POST.
And checkboxes are send as array s
Code:
<?php
//we have now started php and are ready to write the code
$boxes = $_POST["box"]; //get stuff
if($boxes) { //we are checking if the variable is useable if it is we will be able to run the below code if not nothing will happen.
foreach($boxes as $box) {
//First we will set all stuff to be undone
mysql_query("UPDATE `todo` SET `status` = 'undone'") or die(mysql_error());
//and then we will set the checked boxes to be done with a loop going through the array we got.
mysql_query("INSERT INTO `todo` (Id, stuff, status)
VALUES (NULL, '$box', 'done')") or die(mysql_error);
}
}
?>
But with this approach you will need to have mysql database knowledge..
And you'll need to set up a table in the database called 'todo' with the rows id, stuff, status
And trust me things is not always as easy as they seem to be
There are also other ways of doing what you want, like writing to a file.. that would make it able to be moves across servers without having to worry about the database files..
hope this was helpfull