Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

How to assign choosen option value in html_options

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Smarty Development
View previous topic :: View next topic  
Author Message
JulMcl
Smarty n00b


Joined: 27 Sep 2021
Posts: 1

PostPosted: Mon Sep 27, 2021 4:19 pm    Post subject: How to assign choosen option value in html_options Reply with quote

Hi,

I'm developping a front controller for my module of prestashop.

I'm trying to create multiple dropdowns depending of the value choosen on the previous one.

I've got a list of car brand that is assign from php controller, I need to assign the value of the option that has been choosen to generate the next dropdown (because the models depends of the brand)

Here is my actual code :

Code:

<select name="brand" id="brand-select" onchange="setSelectedBrand()">
    <option value=''>{l s="Choose the brand of your car"}</option>
    {foreach from=$brandCategories item=brandCategory}
        {html_options output=$brandCategory.name values=$brandCategory.id_category}
    {/foreach}
</select>

<select name="model" id="model-select">
    <option value="">{l s="Choose the model of your car"}</option>
<select>

<script>

function setSelectedBrand(){
    brandSelector = document.getElementById('brand-select');
    console.log(brandSelector.value);
}

</script>


I need to take the value as I do in Javascript, but I need to do it in Smarty to call then another function and generate a new dropdown (model-select) depending of the value of brand-select.

Is there a way to get it in smarty, or assign a js var to a smarty one without doing any post or get request ?
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Smarty Development All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP