Forums

Link in form button not working

momentis 31 Oct, 2014
I am creating a form containing a button link to an external website. The link is pulled from a custom database table on my site. I am using the following code to generate the button:

<form action="<?php
echo $detail['event_url'];
?>">
    <input class="uk-button uk-button-primary" type="submit" value="Buy Tix" formtarget="_blank">
</form>


I am trying to use this code in order to utilize the button classes in my template, to keep them consistent throughout the site.

When the form runs, I can see that the entire URL is being displayed. However, when I actually click on the button, the URL is truncated at the "?" contained in the URL. You can see this happening in the "Upcoming Events" list on this page http://70.39.235.81/~magicbag/.

I have NO idea what I am doing wrong!!

Rick
BNDragon 03 Nov, 2014
Hi Rick,

Just set a redirect action onSubmit event.

I think that will serve your needs😉

BN
GreyHead 03 Nov, 2014
Hi Rick,

You have nested form tags here which are illegal HTML. I think that probably the parent tag is being used - I'm not sure why it is being truncated though.

I think that there are two choices - you can either turn off the <form> tags for the parent form (setting on the form General tab in CFv4 IIRC); if you do that you should set the form method for the button mini-forms to 'get'

Perhaps easier would be to wrap an <a> link around a button rather than use <form> tags; or set up a style - as BootStrap does - that make a link look like a button.

Bob
momentis 06 Nov, 2014
Bob,

Well, I don't want illegal HTML, so I need to get rid of that. I will try your suggestions and report back.

Thanks!!
Rick
momentis 06 Nov, 2014
Hi Bob,

Your suggestion worked. I simply added the classes I needed to the <a> tag, which got me what I needed.

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