Jump to content

Recommended Posts

Hi guys

 

I have a select combo box 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 combobox to become disabled when an option is selected. I can get these to work seperatly but not together. Is it possible to have 2 onclick 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>

 

I am totally new to java and i'm guessing i need to do something with the fucntion, but have no idea how to do this?

 

thanks

Link to comment
https://forums.phpfreaks.com/topic/244795-select-form-help/
Share on other sites

Hi thanks for reply,

 

unfortunately no luck.... It seems to only like one function?

 

Bot work fine seperatly but not together.

 

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

<form name="filters" id="filters" action="index.php?" method="post">

<Select name='filter11' id="filter11" onChange="submitform(); makeDisable();">

 

Any ideas?

Link to comment
https://forums.phpfreaks.com/topic/244795-select-form-help/#findComment-1257763
Share on other sites

I copied your code as is and it works fine. It disables and submit the form without any problem. If you are submitting to the same page, the select menu will be disabled for a second or two while the page reloads.

 

If you still having a hard time, just make one function that disables and submit the form and call that function from the onchange event.

 

Just a couple of hints, always use a semicolon to terminate each line (e.g. x.disabled=true;)

Link to comment
https://forums.phpfreaks.com/topic/244795-select-form-help/#findComment-1257877
Share on other sites

Hi again nogray, thanks again for your help.

 

It seems the select does submit but only diasbles for 1-2 seconds... The form is submitting to the same page, so I tried including the submit into the same function, but still the same.

<script type="text/javascript">
function makeDisable(){
    document.filters.submit();
     var x=document.getElementById("filter11")
    x.disabled=true
}
</script>
<form name="filters" id="filters" action="index.php?" method="post">

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

Is this function correct, I am very new to java so not sure.

 

Thanks again!

 

Link to comment
https://forums.phpfreaks.com/topic/244795-select-form-help/#findComment-1257888
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.