Categories > TinyButStrong general >

Forms: checkboxes, radio buttons and submission

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Snjv
Date: 2007-07-23
Time: 09:40

Forms: checkboxes, radio buttons and submission

Hello,
I am new to TBS and have been trying to use it for a forum that I am going to develop. Because of the nature of the requirement, I want to find out how to do the basic tasks using TBS. While I was able to implement forms using text fields, drop-down menu and validation, I really do not understand how to dynamically add radio buttons or submit using TBS (ie not relying on template file to make the tasks as it is part of code as I understand).
( Something like in: http://ww.smashits.com/music/hindi-film/songs/1243/taal.html )

From the example that I have come across, we still need to give the radio buttons with name in the tpl file and the info we give in the PHP script could be partial (like colors being RGB in PHP and RGB,Yello,Scarlet in tpl).

Is there a way (or a sample code) by which I can add dynamic checkboxes/radio buttons and submit using PHP and not tpl?

TIA,
-S
By: Snjv
Date: 2007-07-23
Time: 09:45

Re: Forms: checkboxes, radio buttons and submission

Sorry, I just found in sub-templates a  way to submit form (login). But not the source PHP (err "The requested URL /apps/examples/[var..script_name] was not found on this server.") :(
By: Skrol29
Date: 2007-07-23
Time: 10:40

Re: Forms: checkboxes, radio buttons and submission

Hi Snjv,

I don't understand your question:
> Is there a way (or a sample code) by which I can add dynamic
> checkboxes/radio buttons and submit using PHP and not tpl?

You can put your checkbox in the template and it will be multiplicated by the template engine to produce the live dynamic page.
Submitting a form is done the same way as a normal HTML page. You have an example at the Example page of this site (section "Enter data in a form").
There is also a plug-in that helps to preselect items for checkboxex or radiobutons but you probably won't need it.

By: Snjv
Date: 2007-07-23
Time: 13:33

Re: Forms: checkboxes, radio buttons and submission

Thanks! I got it to work. I needed radio buttons for dynamic rows and I followed your suggestion. It works great! I just used it as:

----- <snip> -----

<table width="200" border="1" align="center" cellpadding="2" cellspacing="0">
  <tr bgcolor="#CACACA">
    <th><strong>&nbsp;</strong></th>
    <th><strong>Country</strong></th>
    <th><strong>Prefix</strong></th>
  </tr>

  <tr bgcolor="#F0F0F0">
    <td><input type="radio" name="group1" value="[blk1.key;block=tr]"</td>
    <td>[blk1.key;block=tr]</td>
    <td>[blk1.val]</td>
  </tr>

  <tr bgcolor="#FFCFB9">
    <td colspan="2">[blk1;block=tr;nodata]There is no data. </td>
  </tr>
</table>

----- </snip> -----

The same worked for checkboxes too. I am still wondering why you explicitly gave the boxes in the example code under "      Plug-in: Selecting items"...

Thanks again.
:)