+ 2
I want to print only selected values.How can I do that?
I want to make a form in which input type=checkbox and on submission, a page opens showing something based on selected options.l don't know how to do that. Can I do that using JavaScript or I need to learn php for that? This code gives an idea like what I want to do. https://code.sololearn.com/WF8Yq0RIRZ02/?ref=app
5 ответов
+ 1
Ankur Singh Oli Just do like this
var name = document.getElementsByName('skill');
var message = "You selected -"
for(var i = 0; i < name.length; i++) {
if(name[i].checked)
message = message + " " + name[i].value
}
+ 3
AJ #Infinity Love
Thanks it works.
But if I use form tag then how can I do the same.
+ 3
AJ #Infinity Love
Thanks once again.
+ 1
Ankur Singh Oli Same no need to change anything Because we are getting value using element name. So form tag doesn't matter.