Hello,
I like to create a form in order to organise a Party. If 100 persons decided to visit the party on Monday this radiobutton has to be removed from the form. In order to do so I wrote this PHP code and added it as custom code on load.
Is there a way to deactivate the checkbox at "The miracle happens here", or can i give the value of $partyguests to some Java Script code in order to deactivate the box there?
I like to create a form in order to organise a Party. If 100 persons decided to visit the party on Monday this radiobutton has to be removed from the form. In order to do so I wrote this PHP code and added it as custom code on load.
<?php
$db =& JFactory::getDBO();
$query = "
SELECT *
FROM `#__test2`
WHERE `dayTwoParty` = 1
";
$db->setQuery($query);
$options = $db->loadAssocList();
$partyguests = count($options);
if ($partyguests > "100"){
echo "Zu viele Gäste! <b /r>";
/*The miracle happens here*/
}
?>
Is there a way to deactivate the checkbox at "The miracle happens here", or can i give the value of $partyguests to some Java Script code in order to deactivate the box there?
Hi KristianR,
The simplest way would probably be to add some CSS there to hide the checkbox. Otherwise, as you say, you ca do it with JavaScript.
Bob
The simplest way would probably be to add some CSS there to hide the checkbox. Otherwise, as you say, you ca do it with JavaScript.
<?php
$doc =& JFactory::getDocument();
$db =& JFactory::getDBO();
$query = "
SELECT *
FROM `#__test2`
WHERE `dayTwoParty` = 1
";
$db->setQuery($query);
$options = $db->loadAssocList();
$partyguests = count($options);
if ($partyguests > "100"){
echo "Zu viele Gäste! <br />";
/*The miracle happens here*/
// $doc->addStyleDeclaration('some CSS here');
// or
// $doc->addScriptDeclaration('var party_count = max;');
}
?>
Bob
Hi Bob,
I hate to bother you again with this Question. I tried to find the solution for my problems over the last few days but I can't find it. I tried to disable the checkbox with the id "dayTwoParty" by using CSS. As far as I understand the value of disabled has to be set to "disabled". Therefore I took the <input> part of the checkbox out of the code section, added disabled="disabled" and hoped the best. It sems that the code is acceppted but is not working correctly. "Too many guests!" is printed out but the checkbox is still enabled. Here is my actual code:
Do you can give me a hint in this topic?
I hate to bother you again with this Question. I tried to find the solution for my problems over the last few days but I can't find it. I tried to disable the checkbox with the id "dayTwoParty" by using CSS. As far as I understand the value of disabled has to be set to "disabled". Therefore I took the <input> part of the checkbox out of the code section, added disabled="disabled" and hoped the best. It sems that the code is acceppted but is not working correctly. "Too many guests!" is printed out but the checkbox is still enabled. Here is my actual code:
<?php
$doc =& JFactory::getDocument();
$db =& JFactory::getDBO();
$query = "
SELECT *
FROM `#__test2`
WHERE `dayTwoParty` = 1
";
$db->setQuery($query);
$options = $db->loadAssocList();
$partyguests = count($options);
if ($partyguests > "100"){
/*The miracle happens here*/
$doc->addStyleDeclaration('<input name="dayTwoParty" id="dayTwoParty" value="1" class="A" title="" style="" data-load-state="" data-tooltip="" type="checkbox" disabled="disabled"/>');
echo "Too many guests!<br />";
}
?>
Do you can give me a hint in this topic?
This topic is locked and no more replies can be posted.