Add form depend by value

QuestionsAdd form depend by value
Nicola asked 7 years ago

Hi Abu,
I've a question for add records.

It's possible change default and type by value of field in add form ?

Exemple if value of field TYPE_INSERT is 1 the user can insert a text.
Instead in valude of field TYPE_INSERT is 2 the possibility is true / false by checkbox.

Thanks in advance.

Nicola

4 Answers
Abu Ghufran answered 7 years ago

Hello,

I understand your questions as, you want to change input type of some other field 'X' based on input value of field TYPE_INSERT.
It will need some custom JS code + testing.

If your TYPE_INSERT field is dropdown,
then you can connect onchange event with it and using Jquery code, replace textbox with checkbox html.
e.g.

1) On TYPE_INSERT field, you can set $col["edit_options"]["onchange"] = "function(o){ change_field(o); }";
2) In JS,

<script>
function change_field(o)
{
if (o.value == 1)
$("#X").replaceWith("<input type='checkbox' id='X' name='X' value='true' offval='false' class='FormElement ui-widget-content ui-corner-all' role='checkbox'>");
else
$("#X").replaceWith("<input type='textbox' id='X' name='X' class='FormElement ui-widget-content ui-corner-all' role='textbox'>");
}
</script>

Nicola answered 7 years ago

Thanks Abu for fast answer and perfect solution.

Where can find the the different parameters (example FormElement ui-widget-content ui-corner-all) for improve my application ?

Best regards.
Nicola

Abu Ghufran answered 7 years ago

Hello Nicola,

I checked it via firebug (f12) by inspecting DOM elements.
You can do same.

Abdullah Muhammad answered 7 years ago

Hi,
I thinks its better if you create the full sample codes. Thank you Abu.

Your Answer

16 + 11 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?