Jump to content

[SOLVED] contactform - radio buttons instead of dropdown menu for selecting subject


Recommended Posts

This is actually much trickier than I thought it would be. You can change lines 19-24 of contact-form.tpl from:


{l s='-- Choose --'}
{foreach from=$contacts item=contact}
{$contact.name|escape:'htmlall':'UTF-8'}
{/foreach}



to:

{foreach from=$contacts item=contact}
   <input type="radio" name="id_contact" id="id_contact_{$contact.id_contact|intval}" value="{$contact.id_contact|intval}" style="float: left; padding: 0; width: auto; border: none" />
{$contact.name|escape:'htmlall':'UTF-8'}
{/foreach}



I had to add lots of style code, since the default style causes the radio buttons to display incorrectly. It would be better to move this to global.css if possible.

Also, I had to remove the description that comes up when changing options, since the showElemFromSelect function is expecting a "select" rather than an "input". You'd need to rewrite that function if you want the descriptions to display.

Link to comment
Share on other sites

  • 1 year later...

im actually trying to mess with the tools.js file to show the descriptions, any help?

 

found ansewer..

 

 

add this to /js/tools.js

 

$(document).ready(function() { $('.contact_radio').click(function() { $('.desc_contact').hide(); $('#desc_contact' + $(this).val()).show(); }); });

 

and give the <input type="radio"

 

<input type="radio" id="id_radio1" class="contact_radio" name="id_radio" value="{$contact.id_contact|intval}" onclick="showElemFromSelect('id_radio1', 'desc_contact1')" >

 

 

 

*this is assuming there is jquery loaded.

thanks to Clorith

Edited by brandonc503 (see edit history)
Link to comment
Share on other sites

  • 1 year later...
×
×
  • Create New...