Jump to content

Checkbox in PHP


abhijitp

Recommended Posts

Hi,

I am a newbie and have very little knowledge of PHP. I want to create dependencies on links using a checkbox (or any easier tool).

 

Eg:

Link 1

Link 2

Link 3

 

If the checkbox on link 2 is clicked, then the link 2 should not be active unless Link 1 in opened. Where as Link 3 should be accessible.

 

I have written below code:

 


/* Loop for No. of items/links */

$counter = 0;

foreach ($item as $item_id => $details)
{
    if($details['visible'] == 0)
    {
    		continue;		
    }
	$counter++;


/*Checkbox created */

$typec = "Checkbox";
$namec = "formDoor[]";
$valuec = "";
$checking = "<form method=".'POST'.">".
		"<input type="."'".$typec."'"."name="."'".$namec."'"."value=".$valuec." />".
		"</form>";


/*Dependency condition */


$dsp_ord = '';

$aDoor = $_POST['formDoor'];

$result = "";

if(is_null($aDoor)) 
		{
		 $result =	  	'<td align="left" valign="top">'.'<a href="#" onClick="javascript:window.open('."'".$url."'".	",'mywindow1','width=1000, height=600'".');">'.$url_name . '</a>' . "</td>\n";
		}
    	
		else
		{
		$result =	  	'<td align="left" valign="top">'.'<a href="#">'.$url_name . '</a>' . "</td>\n";
		}

 

With above code the checkbox only appears but doesnt do anything when the page is reloaded, the checkbox is also reloaded. It doesnt get saved.

 

Link to comment
https://forums.phpfreaks.com/topic/169083-checkbox-in-php/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.