Z
Z
zero_machine2016-02-06 02:55:52
MODX
zero_machine, 2016-02-06 02:55:52

How to pass a parameter to the form when calling it through an anchor?

There is a site with a catalog of resources, previews of which are displayed on the main page through pdoTools.
On the preview of each object there is a button for calling the feedback form in the fancibox. How to make it so that the called form would pass the hidden fields of the +pagetitle and +uri values ​​of the preview from which it was called?
Lousy implementation: add a hidden form with predefined values ​​​​to the template for displaying information about the resource (& tpl).
Then 9 (for example) product previews and 9 hidden forms will be displayed on the main page. But this is not only shitty code, but also very sad for the SEO. Therefore, you need to find an implementation option using only one form on the page, the hidden fields of which will be filled with hidden data from the product preview.
123 is replaced with the data-hidden-name value, 321 is replaced with the data-hidden-link value. When the submit button is clicked, the FormIt sends a message. Accordingly, three questions arise:
1) How to do it?
2) How to transfer data from the desired product preview when there are several of them on the page.
3) How to clean up these form values ​​after submission so that you can repeat the maneuver with the next product?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexander Bukhalo, 2016-02-06
@evilsprut

Use the FormIt Plugin

I
Igor, 2016-02-08
@igamov

You can do it with JS. Each time, in theory, there should be a different pagetitle, because. output via pdoTools
Html

<div class="pop-up">
<form method="post">
<input type="hidden" class="my_input">
</form>
</div>

JS
$( "#button" ).click(function(){
    var title = $(this).attr('title');
   $('.pop-up').find('.my_input').val(title);
  });

S
Sergey, 2016-02-16
@Derzaiii

I implemented a similar task like this:
1) I added parameters to the modal window call -
2) Added snippets for pulling these parameters from the
par1 address bar -

<?php echo isset($_GET['par1']) ? $_GET['par1'] : '' ;

par2-
<?php echo isset($_GET['par2']) ? $_GET['par2'] : '' ;

3) Added two hidden fields to the feedback form that is called by the link:
<input type="hidden" name="par1" class="source" value="" />
<input type="hidden" name="par2" class="source" value="" />

4) And the last - in the chunk leaving the mail we insert:
Parameter 1 -
Parameter 2 -

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question