I think I need communication_mode[] rather than communication_mode to
be able to pass all the possible select values to a php file and on to
mysql, but cannot have
if(document.detailsForm.communication_mode[].selectedIndex > -1) {
What do I need to change?
Thanks
Geoff
function verify() {
if(document.detailsForm.communication_mode.selectedIndex > -1) {
sendDetails();
} else {
alert("select one or more");
}
}
function sendDetails() {
params = $('detailsForm').serialize(true);
new Ajax.Updater(
'updateDiv',
'sendDetails_m_s.php',
{
asynchronous:true,
method:'post',
parameters: params
}
);
}
</script>
</head>
<body>
<form id="detailsForm" name="detailsForm" action="#" onsubmit="return
false">
18. Personal preferred communication mode (to select more than one
item click whilst holding down the 'Ctrl' key)<br>
<select name="communication_mode" size= "2" multiple="multiple">
<option value="bsl">BSL</option>
<option value="spoken_language">Spoken language</option>
<option value="sse">SSE</option>
<option value="tc">TC</option>
</select>
<input type="button" value="send" onclick="verify();"/>
</form
<div id="updateDiv"></div>
A small step forward - using communication_mode[] but can I get
<select name="communication_mode[]" size= "2" multiple="multiple">
<option value="bsl">BSL</option>
<option value="spoken_language">Spoken language</option>
<option value="sse">SSE</option>
<option value="tc">TC</option>
</select>
to give me the values in the same order as above? ie if SSE not
selected and the other 3 are I would like to have in the php file say
$result1 = bsl
$resul2 = spken_language
$result3 =
$result4 = tc
Cheers
Geoff
function verify() {
var valid = false;
var s = document.detailsForm.elements['communication_mode[]'];
for (var i = 0; i < s.length; i++) {
if (s[i].selected) {
//alert (s[i].value);
valid = true;
}
}
if (valid == false) {
alert("more");
} else {
sendDetails();