Monday, March 6, 2017

Combine arrays with inputs. Key->value binding

I have a div with input fields.

<div class="tabs">
    <div class="ru">
        <input type="text" name="my_vals_ru[]">
        <input type="text" name="my_keys_ru[]">
    </div>
    <div class="en">
        <input type="text" name="my_vals_en[]">
        <input type="text" name="my_keys_en[]">
    </div>
    <div class="de">
        <input type="text" name="my_vals_ge[]">
        <input type="text" name="my_keys_ge[]">
    </div>
</div>

Also, I have a MySQL table, where I store some custom user data in 3 languages (English, German, Russian).

  • id
  • product_id
  • key_en
  • val_en
  • key_ge
  • val_ge
  • key_ru
  • val_ru

With javascript I can create a lot of such constructions with imputs and send it to process by POST method. Now the question: how can I find out, where the right key->value pair? If it's only one .tabs construction, there's no problem. But what if there're 5 or more? Are there some methods in php or Laravel to manage it?



via J.Tim

Advertisement