Forums

radio clicked to enable select and event on element

aalim 08 Aug, 2011
I'm new to chronoform, and i'm using 4.0rc19.

i searched around the forums but didn't find something that can help me.

i'm using form wizard.

i have a radio button, where the 2 options are
-A: 1 Carton (12 Bottles)
-B: 1 Carton (24 Bottles)

and i have a select menu, Quantity.

how do i make the select menu is disabled by default, disabled when A is clicked and enabled when B is clicked.

attached is the screenshot.

thanks!
GreyHead 11 Aug, 2011
Hi aalim,

There's nothing built into ChronoForms that will do this automatically; you'll need to create a little JavaScript to manage it.

Bob
aalim 12 Aug, 2011
thanks bob! =)
aalim 13 Aug, 2011
Hye,

I put Load JS under show html at the event of on load.
below are the two JS that i tried:
(1) document.getElementById("quantity").disabled = true;
(2) document.forms[0].quantity.disabled=true;
both didn't disabled the select menu which name and id is quantity.

how do i put on click event to a radio? i tried somehting like this, my idea is when i click the radio, an alert appeared.:
$('pack').addEvent('click', function(){
    alert('clicked!');
});

fyi, my radio id is pack

can anyone help me on this?
aalim 13 Aug, 2011
managed to solve this.

i use custom code. and insert the following code.
<script>
window.addEvent('domready', function(){
  $('pack_h12').addEvent('click', function(){
    document.forms[0].quantity.disabled=true;
});
$('pack_h24').addEvent('click', function(){
    document.forms[0].quantity.disabled=false;
});
});
</script>
GreyHead 14 Aug, 2011
Hi aalim,

Just fro your info - you can put this in a Load JS action without the <script> tags and it will be a little tidier on your page.

Bob
This topic is locked and no more replies can be posted.