1

$('.buttonFinish').addClass('btn btn-default');

Jquery code for the submit looks like this:

finish  : $('<a>'+options.labelFinish+'</a>').attr("href","#").addClass("buttonFinish")

I need to replace "#" in href with a variable that I can send thru my PHP code.

I tried to do this:

 finish  : $('<a>'+options.labelFinish+'</a>').attr("href","<?php echo $someVariable;?>").addClass("buttonFinish")

where $someVariable is defined in the PHP code where the form submission link will point to

2 Answers2

1

You can define a variable in php and call it in JS. For example...

PHP

$someVariable = <?php echo $something ?>

JS

finish  : $('<a>'+options.labelFinish+'</a>').attr("href", $someVariable).addClass("buttonFinish")
Nick Tirrell
  • 441
  • 2
  • 13
  • Hey, thanks for the suggestion, the problem is this is breaking the code. This is what the link should look like http://www.mankomal.com/school/form_wizards.html and this is what it looks like after this http://www.mankomal.com/school/addstudent_tpl.html – Mankomal Singh May 20 '18 at 04:49
0
var someVariable = "<?php echo $something ?>";

finish  : $('<a>'+options.labelFinish+'</a>').attr("href", someVariable).addClass("buttonFinish")
  • 1
    Your answer is very similar to the other existing answer. Please clarify the context. Readers might confuse where to put which line, ie a file interpreted by PHP. I suggest adding an example file name and a wrapping – Gogowitsch May 14 '20 at 18:42