OnClick -> add Value to an html file
Posted: Sun Feb 24, 2008 11:46 am
hello all, im having a hard time with this.. hope you can help me...
I Need that if someone will check a checkbox it will check 'this.id.checked == true' [ just check if the checkbox is checked ], and the oppisite too, i mean.. if the checkbox isnt checked, i mean, i want it to know if the checkbox is checked or not.
so.. if im checking a checkbox who wasn't checked before, i want it to run a function in php
the function is gettinf the 'Value' of the checkbox, it doesn't matter if 'Value' or 'Name', one of the two.
and then she puts the value\ name of the checkbox, into a basic html file
My question is if i can do that:
the checkboxes is going in a loop with the pictures [value=picture's name] [ the pictures is getting out from a folder if that makes any difference ].
now if i'm clicking nothing happens.
and here's something ive managed to get through.. but the problem is that he is switching page.
HELP ? ? ?
reminder,
when im clcking an unchecked checkbox, add 'this.value' to a txt\html file. else, pop an alert or something..
maybe this can simple thign for you..
thank you very much !
i really hope you can help me.
Or.
I Need that if someone will check a checkbox it will check 'this.id.checked == true' [ just check if the checkbox is checked ], and the oppisite too, i mean.. if the checkbox isnt checked, i mean, i want it to know if the checkbox is checked or not.
so.. if im checking a checkbox who wasn't checked before, i want it to run a function in php
the function is gettinf the 'Value' of the checkbox, it doesn't matter if 'Value' or 'Name', one of the two.
and then she puts the value\ name of the checkbox, into a basic html file
My question is if i can do that:
the checkboxes is going in a loop with the pictures [value=picture's name] [ the pictures is getting out from a folder if that makes any difference ].
Code: Select all
index.php :
echo '<INPUT TYPE="checkbox" id="dc" onClick="add.php?str=$images[$i]" name="dc'.$i.'" value="'.$images[$i].'" '.$checkedd.' /> ';
Code: Select all
add.php
<?php
$file = fopen($file2, 'a+');
fwrite($file, $_GET['str']);
fclose($file);
?>and here's something ive managed to get through.. but the problem is that he is switching page.
Code: Select all
<?php
$task = $_POST['task'];
switch( $task ) {
case 'CONTINUE':
doContinue();
break;
case 'CANCEL':
doCancel();
break;
default:
doForm();
}
function doForm()
{
?>
<form method="post" action="">
<input type="submit" name="task" value="CONTINUE">
<input type="submit" name="task" value="CANCEL">
</form>
<?php
}
function doContinue() {
echo "CONTINUE";
}
function doCancel() {
echo "CANCEL";
}
?>reminder,
when im clcking an unchecked checkbox, add 'this.value' to a txt\html file. else, pop an alert or something..
maybe this can simple thign for you..
Code: Select all
function update($value)
{
if(checkBoxId.checked == TRUE)
{
// add $value to $file
$file = fopen($file2, 'a+');
fwrite($file, $value);
fclose($file);
}
else
{
// if checkedboxId was allready checked and now its not checked..
// str_replace $value with BLANK
}
}i really hope you can help me.
Or.