Product Comparison Page [closed]

1

I created a page where I first make a choice in a select/list (musical genre), then depending on the choice the second select/list (music) appears with options related to the genre.

What I need is for the items to be chosen (songs) to be included in a list below so that I can then make a choice for comparison (of those in more detail), and each of them can be sent ( via email or pro bank), through checkbox thus ending the process of choice, comparison and submission.

Could anyone help how to do this in PHP and MySQL? Note: I have the initial scripts, but the list on the same page is the one that is screwed ... (type shopping cart only on the same page)

    
asked by anonymous 23.04.2015 / 03:39

1 answer

0

From what I understood your problem is with javascript.

I recommend using a library called jQuery .

With jQuery you can do:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script><script>$('#id-do-select-musica').change(function(){//porconvençãominha,seavariavelconterumobjetojQueryeucomeçoonome//delacom$var$opcaoSelecionada=$(this).find('option:selected');//vocêpodeacessarovalordaoptionselecionadaaquiconsole.log($opcaoSelecionada.val());//podeacessaroconteúdodooptionselecionadotambémconsole.log($opcaoSelecionada.text());//Sequisercopiaraoptionpraoutroselect$opcaoSelecionada.clone().appendTo($('#idDaListaDeMusicasSelecionadas'));});</script>

IrecommendlearningaboutjQuery,it'sverysimpletouseandveryuseful.

Onyourcomment,Ishowedyouhowtogetthevaluesofthevalueattributeoftheselectedoptionwith.val()anditstextualcontentwith.text().

Ifyouwanttocreateacheckboxwiththesevalues,youcanwritethesamejavascriptcheckboxandaddthemtotheelementyouwant:

//criaocheckboxquevocêquercolocarnanovalistavarmeuCheckbox='<inputtype="checkbox" value="'+$opcaoSelecionada.val()+'">';
// adicionar o checkbox ao div com id="meuDiv"
$('#meuDiv').append(meuCheckboc);

You would have to put this code inside the anonymous function that is as a parameter of the .change function I wrote above.

    
23.04.2015 / 07:06