1

i have a parameter in my function JS .. The goal is when i click on my button the parameter should be assigned on new variable Laravel .. i want to pass my data from JS to Laravel

<script type="text/javascript"  >

    function change_theme(color) {

        {{ $idc = color }}//somthing like this 

        document.getElementById('iframe').setAttribute("src","{{(route('generate.pdfColor', ['slug' => 'student', 'id' => '56', 'color' => '$idc']))}}");
    }

</script>
1
  • Why you want to do it?if this variable change frontend elements you can do it whith events of javascript . If this variable will be sent to any action of controller you can define hidden input and populate its value by javascript and pass it. If you describe more about your goal we can help you better. Commented Feb 14, 2020 at 23:03

1 Answer 1

1
<script type="text/javascript">
    function change_theme(color) {
    var url = "{{(route('generate.pdfColor', ['slug' => 'student', 'id' => '56', 'color' => ':id']))}}";
        url = url.replace('%3Aid',color);
        document.getElementById('iframe').setAttribute("src", url);
    }
</script>

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.