I have a pulldown menu created from PHP querying a database and then using foreach loop creating a list of options for that pull down menu.
However in my form users may require to enter more of the same fields so I was wondering is it possible to make JavaScript copy an element like a pulldown with all its values and then place duplicate it in the same form?
Why I am thinking like this, because I can’t seem to find a way to pass a PHP array to JavaScript or at least I can’t find a way to do it 🙁
I don’t remember the plain javascript way, with jQuery you can use the clone method, however I’d not use this approach because you’ll get same post names. Better to do this in php unless you need a dynamic form. In that case clone is the solution, but keep an eye on input names when doing that.