You are here: Re: Tick all checkboxes « PHP Programming Language « IT news, forums, messages
Re: Tick all checkboxes

Posted by Paul Morrison on 10/12/68 11:39

Thanks guys, got that sorted now, I didnt realise that you could put
Javascript into a php file.

I now have another problem with the checkboxes. I set up my form as follows:

<form method="get" action="sub.php">
<div align="left" style="font-size:12px ;clear : both">
<input type=button name="CheckAll" value="Check All"
onClick="modify_boxes(true,4)" style="font-size:10px"/>
<input type=button name="UncheckAll" value="Uncheck All"
onClick="modify_boxes(false,4)" style="font-size:10px"/><p/>
<div style="width:10px"></div><input type="checkbox"
name="subscription" value="economic" id="economic"/><label
for="economic">Economic</label><br/>
<div style="width:10px"></div><input type="checkbox"
name="subscription" value="environmental" id="environmental"/><label
for="environmental">Environmental</label><br/>
<div style="width:10px"></div><input type="checkbox"
name="subscription" value="political" id="political"/><label
for="political">Political</label><br/>
<div style="width:10px"></div><input type="checkbox"
name="subscription" value="social" id="social"/><label
for="social">Social</label><br/>
<br><input type="submit" value="Submit" style="font-size:10px"/>
</div>
<input type="hidden" name="add_subscription" value="1"/>
</form>

Once the user ticks the boxes that apply to them, they click the submit
button and I want to go through the boxes. I am using the following type of
statement:

if('".$subscription[0]."'==0){
$query = "INSERT INTO inj_subscription VALUES ('$user' , 'economic' ,
NULL);";
$result = mysql_query($query) or die('Error during subscription process,
please refresh the page and try again');
if($result){
echo '<p style="color:red">Subscription Successful</p>';
}
}

The clause that I use to get into the loop is:

if($_GET['add_subscription']==1){

The problem is that the code I have written checks whether the boxes are
ticked when the page loads up, rather than after the user clicks the submit.
I know that loop worked before as I was using radio buttons rsther than
checkboxes, is this the wrong assumption to make?

Any help would be much appreciated.

Paul

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация