Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

pass select values to php?

0 views
Skip to first unread message

Geoff

unread,
Mar 13, 2010, 8:09:23 AM3/13/10
to
Hello

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>

Geoff

unread,
Mar 13, 2010, 10:35:07 AM3/13/10
to
On Sat, 13 Mar 2010 13:09:23 +0000, Geoff <ge...@invalid.com> wrote:

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();

0 new messages