Forums

DELETE VALUE OF SELECT BOX AFTER SUBMIT

solfri 04 May, 2012
Hi People, i wanna ask you something.

i have a form with select box with different values
i want when one people choose one value of select box and click on submit
delete the value from the select box and remain the other value.
i have custom code with this code
<?php
if ( $form->data['select'] == '1') {
  $db =& JFactory::getDBO();
  $query = 'UPDATE `jos_chronoforms` SET `content` = '<div class="ccms_form_element cfdiv_select multiline_start multiline_add" id="select_container_div"><label for="select">SELECT</label><select size="1" id="select" class="" title="" name="select"><option value="2">2</option><option value="3">3</option><option value="4">4</option></select><div class="clear"></div><div id="error-message-select"></div></div><div class="ccms_form_element cfdiv_submit" id="autoID-637e4a043cb63f2fc21335a1ede89e29_container_div"><input name="input_submit_12" class="" value="INVIA" type="submit" /><div class="clear"></div><div id="error-message-input_submit_12"></div></div>';
";
$db->setQuery($query);
$db->query();
}
?>

and before i have the db save
with the table jos_chornoform and model id content
this is the debug:
Data Array: 
Array
(
    [select] => 1
    [input_submit_12] => INVIA
    [039b288a50a4cb123270bd937576cb37] => 1
    [option] => com_chronoforms
    [chronoform] => PROVASELECT
    [event] => submit
    [Itemid] => 
    [content] => Array
        (
            [cf_uid] => 53d0234d6057d4748471f208242f0bbc
            [cf_created] => 2012-05-04 12:33:07
            [cf_ipaddress] => some ip
            [cf_user_id] => 0
            [select] => 1
            [input_submit_12] => INVIA
            [039b288a50a4cb123270bd937576cb37] => 1
            [option] => com_chronoforms
            [chronoform] => PROVASELECT
            [event] => submit
            [Itemid] => 
            [id] => 52
        )

    [content_id] => 52
)

nothing happen, it only create a new table in jos_chornoform with null value in the db
Help me please.
GreyHead 04 May, 2012
Hi solfri,

Don't **ever** try to amend a form like this - there's a 99% probability that it will break.

Save the options in a database table or a text file and use the Dynamic Data tab to create the Select drop down options. Delete the selected one with a simple MySQL query in a Custom action. Then next time you'll juet get the new option list.

Bob
solfri 04 May, 2012
Please Bob can you give me a simple pratice example? im very confused. thanks.
GreyHead 04 May, 2012
Hi solfri,

I can try but please explain to me exactly what you want to have happen with this form? What kind of options are these and why do you want them to be deleted?

This will help me work out a good way to solve it.

Bob
solfri 04 May, 2012
Simple.
a form with select box with some option:
1=1
2=2
3=3
4=4
and submit button
i wanna make like a exlusion
every time peple select a value
in the tanks message i wanna put
Tanks, you choice is stored.
after if someone open the same page with form
i wanna only the people can see the rest of value without the value choose before.
The concept is this after i wanna apply some other that i know the process.
Tanks Bob for your help.
GreyHead 26 May, 2012
Hi solfri,

Did you find a solution for this?

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