Forums

Where box depending on radio button selection

federico85 04 Dec, 2012
Hello...
I'm trying to set up a connection using CC.
In the header box - in custom listing - I created a form with some radio button and a submit button like this:

<input type="radio" rel="cat_radio0" name="radio0" value="radio0" /> radio0
<input type="radio" rel="cat_radio1" name="radio1" value="radio1" /> radio1
<input type="radio" rel="cat_radio2" name="radio2" value="radio2" /> radio2
<input type="radio" rel="cat_radio3" name="radio3" value="radio3" /> radio3
<input type="radio" rel="none" name="radio4" value="radio4" /> radio4
<td>
<input type="submit" value="Search" height = "20px" width= "40px" />
</td>

I want the WHERE box to depend on users radio choice.

Example: if radio0 is selected echo "`field` = 'Yes' ";

I tried to do it putting in WHERE BOX this code but it doesn't work:

<?php
if ( isset($form->data['radio0'])) {
echo "`field` = 'Yes'";
}
else {
echo "'xxx'";
}
?>

Could someone help me understanding what's wrong?
I'm not so good at coding and maybe if I see some example code for doing this I can adapt it to my needs...
Thanks in advance...
GreyHead 04 Dec, 2012
Hi federico85,

Please try:
<?php
if ( isset($form->data['radio0']) && $form->data['radio0'] ) {
  echo " `field` = 'Yes' ";
}
?>

Bob
federico85 04 Dec, 2012
Maybe I got a little bit confused and i copied the wrong part of my form😶 ...
This is my html code:
    
<input type="radio" rel="cat_radio0" name="radio" value="radio0" /> radio0
<input type="radio" rel="cat_radio1" name="radio" value="radio1" /> radio1
<input type="radio" rel="cat_radio2" name="radio" value="radio2" /> radio2
<input type="radio" rel="cat_radio3" name="radio" value="radio3" /> radio3
<input type="radio" rel="none" name="radio" value="radio4" /> radio4
<td>
<input type="submit" value="Search" height = "20px" width= "40px" />
</td>


and in the where box i need something like:


if radio = 'radio0' -> value of radio
echo " `field` = 'Yes' ";


I don't know why but i can't understand how to retreive values from radio buttons...🤨
federico85 05 Dec, 2012
i tried as described in this http://www.chronoengine.com/forums.html?cont=posts&f=12&t=19933 topic:
$lookingfor = JRequest::getVar('lookingfor', '', 'post');

and it worked...

Another doubt:
I saw that CC uses by default ORDER BY cf_id.
Is there a way to change it and order records by other (multiple fields)?

For example:

$trial = JRequest::getVar('raidio', '', 'post');
$trial1 = JRequest::getVar('raidio1', '', 'post');

if ($trial = '10')  {
echo "WHERE `field`= 'xxx' ORDER BY `name` DESC, `last_name`  ASC";
}

if ($trial1 = '10')  {
echo "WHERE `field`= 'xxx' ORDER BY `name` ASC, `last_name`  DESC";
}
GreyHead 07 Dec, 2012
Hi federico85,

Which version of ChronoConnectivity are you using? The post you liked to was for the older version.

In the current version you can use more than one column name in the ORDER BY box. In the older version you could add a compound ORDER BY clause in the WHERE box using code like the example you posted.

Bob
This topic is locked and no more replies can be posted.