Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show Message based on previous selected item #4492

Closed
go-sudo opened this issue Jun 22, 2022 · 10 comments
Closed

Show Message based on previous selected item #4492

go-sudo opened this issue Jun 22, 2022 · 10 comments
Labels

Comments

@go-sudo
Copy link

go-sudo commented Jun 22, 2022

Are you requesting a feature, reporting a bug or asking a question?

Question

What is the current behavior?

I'm using smarty to show date of the selected item only (checkbox or dropdown)

but the messages display the information of all item, even those are not selected

What is the expected behavior?

I would like to display the information for only the selected item

How would you reproduce the current behavior (if this is a bug)?

Provide the test code and the tested page URL (if applicable)

Tested page URL:

https://i.im.ge/2022/06/23/uXGcBW.gif


{literal}
        <script type="text/javascript">Survey
    .StylesManager
    .applyTheme("defaultV2");

var json = {
  "pages": [
    {
      "locale": "fr",
      "name": "page1",
      "elements": [
              {
         "type": "radiogroup",
          "name": "Commandes",
         "isRequired": true,
         "title": "Merci de choisir la commande",
          "colCount": 3,
          "choicesOrder": "asc",
          "choices": [ {/literal}  {foreach from=$orders item=order}
            "{$order.details.reference}",
        
          {/foreach}{literal}  ]
        },{
             
     "type": "html",
     "name": "DétailsCommande",
       "isRequired": false,
        "visibleIf": "{Commandes.length} > 1",
        "title": " ",
        "choicesFromQuestion": "Commandes",
         "choicesFromQuestionMode": "selected",
<!--it should shows the order date of the selected   "name": "Commandes"-->
     "html": "{/literal}  {foreach from=$orders item=order} {$order.details.order_date}{/foreach}{literal}"
    },

Specify your

  • browser:Chrome
  • browser version:Version 102.0.5005.115 (Official Build) (64-bit)
  • surveyjs platform jquery
  • surveyjs version:1.9.2
@andrewtelnov
Copy link
Member

@go-sudo Could you please provide the JSON or plunker with the real data?

Thank you,
Andrew

@go-sudo
Copy link
Author

go-sudo commented Jun 25, 2022

Hello @andrewtelnov

I can not post real data with smarty, I get a suggestion from a good friend, but I do not know how to implent it with survey

https://plnkr.co/edit/oRSKRQ9Cx8yU3aDv

<script> var my_date_aray = [];{/literal} {foreach from=$orders item=order} my_date_aray["{$order.details.reference}"] = "{$order.details.order_date}"; {/foreach} {literal} </script>

the issue that when I select on the dropdown an order, the html show the expiration date for all orders available on the dropdown (unsellected) and not the only the selected one

Regards

@andrewtelnov
Copy link
Member

@go-sudo Unfortunately, your example doesn't work. We need the real data to see the issue.

Thank you,
Andrew

@go-sudo
Copy link
Author

go-sudo commented Jun 25, 2022

Hello @andrewtelnov

Please do not close this issue, I will make a html example for your

I let you know that it works when i change the type from html to checkbox but I need to display the information as text or html
https://watch.screencastify.com/v/bVMqeguvdwrvwx977Tml

pages": [
    {
      "locale": "fr",
      "name": "page1",
      "elements": [
              {
         "type": "radiogroup",
          "name": "Commandes",
         "isRequired": true,
         "title": "Merci de choisir la commande",
          "colCount": 3,
          "choicesOrder": "asc",
          "choices": [ {/literal}  {foreach from=$orders item=order}
            "{$order.details.reference}",
        
          {/foreach}{literal}  ]
        },{
"type": "checkbox",
"name": "fin",
 "isRequired": false,
"visibleIf": "{Commandes.length} > 0",
//"choicesVisibleIf":"{Typologie} contains {item}",
"choices": [
 {/literal}  {foreach from=$orders item=order}
{ "value": "{$order.details.reference}", "text": "{$order.details.order_date}"},{/foreach}{literal}

],
  "choicesVisibleIf": "{Commandes} contains {item}"
},

@go-sudo
Copy link
Author

go-sudo commented Jun 26, 2022

Hi @andrewtelnov

here is a demo based on html https://plnkr.co/edit/hV6XK8V6A9v78cFz

regards

@andrewtelnov
Copy link
Member

@go-sudo opSystem should be "checkbox". Here is the updated example
You are requested opSystem value to be an array.

Thank you,
Andrew

@go-sudo
Copy link
Author

go-sudo commented Jun 27, 2022

Hello @andrewtelnov

unfortunately, this is not what I'm looking for

The order N1 will expire the 1 june 202
the order N2 will expire the 3 aout 2023
the order N3 will expire the 10 novembre 2023

so when user click on order N2 he will get a message for only and only the selected order

I try to make this work with HTML, and then I will use smarty

Regards

@go-sudo
Copy link
Author

go-sudo commented Jun 28, 2022

{
"type": "dropdown",
"name": "ManagerGID",
"choices": [
{ "value": "item1", "text": "laim"},
{ "value": "item2", "text": "baoe"},
{ "value": "item3", "text": "lij"},
{ "value": "item4", "text": "t74104"},
{ "value": "item5", "text": "wangch"},
{ "value": "item6", "text": "z41928"}
]
},

{
  "type": "html",
  "name": "EmployeeGID",
  "title": "GID",
  "choices": [
  { "value": "item2", "text": "xur"},
  {"value": "item3", "text": "q73500"},
  { "value": "item3", "text": "p41145"}, 
  { "value": "item2", "text": "j27411"},
  { "value": "item2", "text": "x41239"},
  { "value": "item3", "text": "n10054"},
  { "value": "item3", "text": "h41083"},
  { "value": "item3", "text": "e92313"},
  { "value": "item3", "text": "d65777"},
  {  "value": "item5", "text": "w62868"},
  { "value": "item5", "text": "w47783"},
  { "value": "item5", "text": "u18625"},
  { "value": "item5", "text": "t62294"},
  { "value": "item5", "text": "liud"},
  { "value": "item5", "text": "b37997"},
  { "value": "item5", "text": "b23037"},
  { "value": "item5", "text": "x72889"},
  { "value": "item6", "text": "z63524"},
  { "value": "item6", "text": "z00201"},
  { "value": "item6", "text": "y59417"},
  { "value": "item6", "text": "x08640"},
  { "value": "item6", "text": "u72542"},
  { "value": "item6", "text": "t46383"},
  { "value": "item6", "text": "h71847"},
  { "value": "item6", "text": "e07862"},
  { "value": "item2", "text": "m99743"},
  { "value": "item2", "text": "s73614"},
  { "value": "item1", "text": "s59193"},
  { "value": "item1", "text": "a44493"},
  { "value": "item1", "text": "m41154"},
  { "value": "item4", "text": "n62878"},
  { "value": "item4", "text": "f72163"},
  { "value": "item4", "text": "n18106"},
  { "value": "item4", "text": "y96414"},
  { "value": "item4", "text": "f51397"},
  { "value": "item4", "text": "s75248"},
  { "value": "item4", "text": "f33580"},
  { "value": "item4", "text": "d00307"}
  ],
   "choicesVisibleIf": "{ManagerGID} contains {item}"
  
}

@go-sudo
Copy link
Author

go-sudo commented Jun 28, 2022

hi @andrewtelnov

like this one #1046 but instead of dropdown i need to show text please

@go-sudo
Copy link
Author

go-sudo commented Jul 3, 2022

Hi @andrewtelnov

Thanks to you, I Found a solution to my issue, I appreciate your help

@go-sudo go-sudo closed this as completed Jul 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants