...

View Full Version : Form help



amg182
08-25-2011, 10:01 PM
Hi guys

I have a select "combobox" that when you click on an option from the list it submits the value, which is what i want it to do. But I would also like to have the select "combobox" become disabled or greyed out after an option is selected. I can get these to work seperatly but not together. Is it possible to have 2 onchange events in one form?


here is what i am working with:

<script type="text/javascript">
function makeDisable(){
var x=document.getElementById("filter11")
x.disabled=true
}
</script>

<td><Select name='filter11' id="filter11" onChange="filters.submit();" onchange="makeDisable()">
<option value=''>Months (Any)</option>
blah blah
</select>

Fou-Lu
08-25-2011, 10:11 PM
Despite the similar sounding names, Java is not the same as Javascript.
Moving from Java forum to Javascript forum.

amg182
08-25-2011, 10:40 PM
Apologies...:thumbsup:

Old Pedant
08-25-2011, 11:06 PM
Just call both functions from the *SINGLE* onchange.



<Select name='filter11' id="filter11" onChange="filters.submit();makeDisable()">

amg182
08-25-2011, 11:12 PM
Hi Old pendant.

Yeah I did try that, it submits the form ok, but it only disables the form for 1 second... I have the form submiting to the same page.(index.php) Should that matter?

Old Pedant
08-26-2011, 12:29 AM
Oh...once you submit the <form>, the server *RELOADS* the ENTIRE PAGE. So any changes you make via JavaScript will be completely lost in the re-loaded page.

You will need to take care of this in you server-side code. That is, if this is a PHP page, use PHP code to detect that the <select> has been used and disable it via PHP. (Or ASP or JSP or whatever.)

amg182
08-26-2011, 12:59 AM
ah, I see. That makes sense!

Will have a go with the php script!

Thanks:)

Philip M
08-26-2011, 08:32 AM
Or you could use a Javascript cookie.



But I would also like to have the select "combobox" become disabled or greyed out after an option is selected.

Why? That means that the user cannot change his mind. Surely a user-hostile approach!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum