Reputation: 47
I have a radiobutton and the value gets submitted with a submitbutton. I only want a submitbutton that submits the value when clicked. So instead of a radiobutton and a submitbutton separate I want a radiobutton and submit button rolled into 1.
This is my code:
{foreach item=item key=key from=$memberships}
<input type="radio" type="hidden" name="membership" value="{$key}" checked="checked"/>
{$item}
{/foreach}
<input class="button" type="submit" value="{lang mkey='continue'} -->"/>
What I am trying to achieve is something like this:
replace the radiobutton and submit button with just a submit button.
<button type="submit" name="membership" value="{$key}">{$item}</button>
Would it be possible and how to do it?
Upvotes: 0
Views: 684
Reputation: 14630
Just don't have a submit button, and then use an onclick event for the radio button that submits the form.
Upvotes: 0
Reputation: 195
You could create a small image that looks like a radio button and map that as your submit button. This would give the illusion of having a radio button but when a user clicks it your form would submit.
If you really want to jazz it up, have a second image like a selected radio button and show that with something like an onClick() event.
Upvotes: 0
Reputation: 2476
You can have
<input type="radio" type="hidden" name="membership" value="{$key}" checked="checked" onclick="this.form.submit();"/>
or
<input type="hidden" type="hidden" name="membership" id="membership" value="{$key}">
<button type="submit" name="membership" onclick="document.formname.membership.value={$key}; return true;">{lang mkey='continue'}</button>
Upvotes: 1