I tried to select all options of multi-slect flower[ ] using javascript but nothing happened when I click on submit, please tell what wrong ?
<html>
<head>
<script language="javascript" type="text/javascript">
$("#submit").click(function() {
$('#flower option').each(function() {
$(this).attr('selected', true);
});
});
</script>
</head>
<body>
<form method="Get" action="#">
<select name="flower[ ]" id="flower" multiple>
<option value="flower">FLOWER</option>
<option value="rose">ROSE</option>
<option value="lilly">LILLY</option>
<option value="jasmine">JASMINE</option>
<option value="lotus">LOTUS</option>
<option value="tulips">TULIPS</option>
</select>
<input type="submit" id="submit" name="submit" value="submit">
</form>
</body>
</html>
event.preventDefault()and give your function aneventparameter. Also try doing a test case, for example doconsole.log()in the functions you thing are not working, to check they are being ran.