{"id":8629,"date":"2014-09-11T06:11:50","date_gmt":"2014-09-11T06:11:50","guid":{"rendered":"http:\/\/www.greytrix.com\/blogs\/sagecrm\/?p=8629"},"modified":"2019-12-05T05:55:59","modified_gmt":"2019-12-05T05:55:59","slug":"linked-selection-fields-through-client-side-scripting","status":"publish","type":"post","link":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2014\/09\/11\/linked-selection-fields-through-client-side-scripting\/","title":{"rendered":"Linked selection fields through client side scripting"},"content":{"rendered":"<p>Today I will revisit one of the oldest, but very much useful tricks related to web forms. Most of the forms nowadays need relationship to be established between two fields. For example when I select Product interest in one list it should filter Sub product interest in another field. Today I will explain how this can be achieved on Sage CRM screens through fairly simple configurations and client side scripting<br \/>\n<span style=\"color: #993300;\"><em><strong>New Stuff:<\/strong><\/em><\/span>&nbsp; <a title=\"Sage CRM and IIS authentication settings\" href=\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2014\/09\/06\/sage-crm-and-iis-authentication-settings\/\" target=\"_blank\" rel=\"noopener noreferrer\">Sage CRM and IIS authentication settings<\/a><br \/>\nLet\u2019s consider an example, in Person screen we want to filter \u201c<strong>Sub Selection<\/strong>\u201d (pers_subselection) field based on the value selected in \u201c<strong>Main Selection<\/strong>\u201d (pers_mainselection) field. Before moving ahead we need to configure values in both this field using some logic so that it can be filtered easily using jQuery. The logic that I have used is the code value of \u201c<strong>Main Selection<\/strong>\u201d needs to be available in code of \u201c<strong>Sub Selection<\/strong>\u201d field i.e. based on code \u201cA\u201d I can search \u201cA1, A2\u201d. When we define this logic in fields it becomes easier for configurations in case new options are getting added over the time. We don\u2019t have to go to server side for querying option values from translations in that case which means faster processing.<br \/>\n<a href=\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-content\/uploads\/2014\/09\/Image1.jpg\" target=\"_blank\" rel=\"noopener noreferrer\"><img fetchpriority=\"high\" decoding=\"async\" class=\"aligncenter wp-image-8635 size-full\" src=\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-content\/uploads\/2014\/09\/Image1.jpg\" alt=\"Image1\" width=\"622\" height=\"176\"><\/a><br \/>\nAfter configuring the values, we need to add below syntax in the Custom content of the screen where we have added above two fields.<br \/>\n<span style=\"color: #3366ff;\"><em>&lt;script language=&#8217;javascript&#8217;&gt;<\/em><\/span><br \/>\n<span style=\"color: #3366ff;\"><em>if(window.attachEvent)<\/em><\/span><br \/>\n<span style=\"color: #3366ff;\"><em>{<\/em><\/span><br \/>\n<span style=\"color: #3366ff;\"><em> window.attachEvent(&#8220;onload&#8221;,FilterSelection);<\/em><\/span><br \/>\n<span style=\"color: #3366ff;\"><em>}<\/em><\/span><br \/>\n<span style=\"color: #3366ff;\"><em>else if(window.addEventListener)<\/em><\/span><br \/>\n<span style=\"color: #3366ff;\"><em>{<\/em><\/span><br \/>\n<span style=\"color: #3366ff;\"><em> window.addEventListener(&#8216;load&#8217;, FilterSelection, false);<\/em><\/span><br \/>\n<span style=\"color: #3366ff;\"><em>}<\/em><\/span><br \/>\n<span style=\"color: #3366ff;\"><em>function FilterSelection()<\/em><\/span><br \/>\n<span style=\"color: #3366ff;\"><em>{<\/em><\/span><br \/>\n<span style=\"color: #3366ff;\"><em> var options = $(&#8220;#pers_subselection&#8221;).html();<\/em><\/span><br \/>\n<span style=\"color: #3366ff;\"><em> $(&#8220;#pers_mainselection&#8221;).change(function(e) {<\/em><\/span><br \/>\n<span style=\"color: #3366ff;\"><em> var text = $(&#8220;#pers_mainselection :selected&#8221;).text();<\/em><\/span><br \/>\n<span style=\"color: #3366ff;\"><em> $(&#8220;#pers_subselection&#8221;).html(options);<\/em><\/span><br \/>\n<span style=\"color: #3366ff;\"><em> if (text == &#8220;&#8211;None&#8211;&#8220;) return;<\/em><\/span><br \/>\n<span style=\"color: #3366ff;\"><em> $(&#8216;#pers_subselection :not([value^=&#8221;&#8216;+ text +'&#8221;])&#8217;).remove();<\/em><\/span><br \/>\n<span style=\"color: #3366ff;\"><em> $(&#8220;#pers_subselection&#8221;).append(&#8220;&lt;option value=&#8221; selected=true&gt;&#8211;None&#8211;&lt;\/option&gt;&#8221;);<\/em><\/span><br \/>\n<span style=\"color: #3366ff;\"><em> });<\/em><\/span><br \/>\n<span style=\"color: #3366ff;\"><em>}<\/em><\/span><br \/>\n<span style=\"color: #3366ff;\"><em>&lt;\/script&gt;<\/em><\/span><br \/>\nAfter adding above script, you will be able to filter the values from above 2 fields as displayed in following screenshot.<br \/>\n<a href=\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-content\/uploads\/2014\/09\/Img.jpg\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"aligncenter wp-image-8636 size-full\" src=\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-content\/uploads\/2014\/09\/Img.jpg\" alt=\"Img\" width=\"812\" height=\"318\"><\/a><br \/>\nHappy scripting!<br \/>\n<span style=\"color: #993300;\"><em><strong>Also Read:<\/strong><\/em><\/span><br \/>\n1) <a title=\"Sort Dropdown list items using jQuery\" href=\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2013\/03\/02\/sort-dropdown-list-items-using-jquery\/\" target=\"_blank\" rel=\"noopener noreferrer\">Sort Dropdown list items using jQuery<\/a><br \/>\n2) <a title=\"Sorting Country Selection\" href=\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2011\/04\/16\/sorting-country-selection\/\" target=\"_blank\" rel=\"noopener noreferrer\">Sorting Country Selection<\/a><br \/>\n3) <a title=\"Dropdown Sync in Sage CRM System\" href=\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2011\/10\/13\/dropdown-sync-in-sage-crm-system\/\" target=\"_blank\" rel=\"noopener noreferrer\">Dropdown Sync in Sage CRM System<\/a><br \/>\n4) <a title=\"Changing max allowable length of Text field using Jquery\" href=\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2013\/03\/11\/changing-max-allowable-length-of-text-field-using-jquery\/\" target=\"_blank\" rel=\"noopener noreferrer\">Changing max allowable length of Text field using Jquery<\/a><br \/>\n5) <a title=\"Limit number of characters in Sage CRM fields\" href=\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2014\/08\/18\/limit-number-of-characters-in-sage-crm-fields\/\" target=\"_blank\" rel=\"noopener noreferrer\">Limit number of characters in Sage CRM fields<\/a><br \/>\n&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today I will revisit one of the oldest, but very much useful tricks related to web forms. Most of the forms nowadays need relationship to be established between two fields. For example when I select Product interest in one list it should filter Sub product interest in another field. Today I will explain how this\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2014\/09\/11\/linked-selection-fields-through-client-side-scripting\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[155,200,219,267,332,357,373,1],"tags":[1143,1471,1532,1695,2259,2313],"class_list":["post-8629","post","type-post","status-publish","format-standard","hentry","category-fields","category-javascript-sage-crm","category-list","category-on-change","category-sage-crm","category-selection","category-sort","category-uncategorized","tag-fields","tag-javascript","tag-list","tag-on-change","tag-selection","tag-sort"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Linked selection fields through client side scripting - Sage CRM \u2013 Tips, Tricks and Components<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2014\/09\/11\/linked-selection-fields-through-client-side-scripting\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Linked selection fields through client side scripting - Sage CRM \u2013 Tips, Tricks and Components\" \/>\n<meta property=\"og:description\" content=\"Today I will revisit one of the oldest, but very much useful tricks related to web forms. Most of the forms nowadays need relationship to be established between two fields. For example when I select Product interest in one list it should filter Sub product interest in another field. Today I will explain how this\u2026 Read More &raquo;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2014\/09\/11\/linked-selection-fields-through-client-side-scripting\/\" \/>\n<meta property=\"og:site_name\" content=\"Sage CRM \u2013 Tips, Tricks and Components\" \/>\n<meta property=\"article:published_time\" content=\"2014-09-11T06:11:50+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-12-05T05:55:59+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-content\/uploads\/2014\/09\/Image1.jpg\" \/>\n<meta name=\"author\" content=\"greysagecrm\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"greysagecrm\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2014\/09\/11\/linked-selection-fields-through-client-side-scripting\/\",\"url\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2014\/09\/11\/linked-selection-fields-through-client-side-scripting\/\",\"name\":\"Linked selection fields through client side scripting - Sage CRM \u2013 Tips, Tricks and Components\",\"isPartOf\":{\"@id\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2014\/09\/11\/linked-selection-fields-through-client-side-scripting\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2014\/09\/11\/linked-selection-fields-through-client-side-scripting\/#primaryimage\"},\"thumbnailUrl\":\"http:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-content\/uploads\/2014\/09\/Image1.jpg\",\"datePublished\":\"2014-09-11T06:11:50+00:00\",\"dateModified\":\"2019-12-05T05:55:59+00:00\",\"author\":{\"@id\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/#\/schema\/person\/e7ff1c8f4763b47730d6bc5e74d59c1f\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2014\/09\/11\/linked-selection-fields-through-client-side-scripting\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2014\/09\/11\/linked-selection-fields-through-client-side-scripting\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2014\/09\/11\/linked-selection-fields-through-client-side-scripting\/#primaryimage\",\"url\":\"http:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-content\/uploads\/2014\/09\/Image1.jpg\",\"contentUrl\":\"http:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-content\/uploads\/2014\/09\/Image1.jpg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2014\/09\/11\/linked-selection-fields-through-client-side-scripting\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Linked selection fields through client side scripting\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/#website\",\"url\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/\",\"name\":\"Sage CRM \u2013 Tips, Tricks and Components\",\"description\":\"Explore the possibilities with Sage CRM insights through our comprehensive blogs. As a leading Sage partner, Greytrix helps businesses maximize their Sage CRM potential with its rich expertise and immense knowledge. Here, you will find blogs that feature expert advice, tips &amp; tricks, best practices, and comprehensive guides on customizing and configuring Sage CRM for your business. Stay informed with our regular updates and expert insights!\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/#\/schema\/person\/e7ff1c8f4763b47730d6bc5e74d59c1f\",\"name\":\"greysagecrm\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/c3b4325cb326e36467f945b9b9adf2bb85e907fe092d42eb36b39743b492e626?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/c3b4325cb326e36467f945b9b9adf2bb85e907fe092d42eb36b39743b492e626?s=96&d=mm&r=g\",\"caption\":\"greysagecrm\"},\"url\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/author\/greysagecrm\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Linked selection fields through client side scripting - Sage CRM \u2013 Tips, Tricks and Components","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2014\/09\/11\/linked-selection-fields-through-client-side-scripting\/","og_locale":"en_US","og_type":"article","og_title":"Linked selection fields through client side scripting - Sage CRM \u2013 Tips, Tricks and Components","og_description":"Today I will revisit one of the oldest, but very much useful tricks related to web forms. Most of the forms nowadays need relationship to be established between two fields. For example when I select Product interest in one list it should filter Sub product interest in another field. Today I will explain how this\u2026 Read More &raquo;","og_url":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2014\/09\/11\/linked-selection-fields-through-client-side-scripting\/","og_site_name":"Sage CRM \u2013 Tips, Tricks and Components","article_published_time":"2014-09-11T06:11:50+00:00","article_modified_time":"2019-12-05T05:55:59+00:00","og_image":[{"url":"http:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-content\/uploads\/2014\/09\/Image1.jpg","type":"","width":"","height":""}],"author":"greysagecrm","twitter_card":"summary_large_image","twitter_misc":{"Written by":"greysagecrm","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2014\/09\/11\/linked-selection-fields-through-client-side-scripting\/","url":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2014\/09\/11\/linked-selection-fields-through-client-side-scripting\/","name":"Linked selection fields through client side scripting - Sage CRM \u2013 Tips, Tricks and Components","isPartOf":{"@id":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2014\/09\/11\/linked-selection-fields-through-client-side-scripting\/#primaryimage"},"image":{"@id":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2014\/09\/11\/linked-selection-fields-through-client-side-scripting\/#primaryimage"},"thumbnailUrl":"http:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-content\/uploads\/2014\/09\/Image1.jpg","datePublished":"2014-09-11T06:11:50+00:00","dateModified":"2019-12-05T05:55:59+00:00","author":{"@id":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/#\/schema\/person\/e7ff1c8f4763b47730d6bc5e74d59c1f"},"breadcrumb":{"@id":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2014\/09\/11\/linked-selection-fields-through-client-side-scripting\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.greytrix.com\/blogs\/sagecrm\/2014\/09\/11\/linked-selection-fields-through-client-side-scripting\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2014\/09\/11\/linked-selection-fields-through-client-side-scripting\/#primaryimage","url":"http:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-content\/uploads\/2014\/09\/Image1.jpg","contentUrl":"http:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-content\/uploads\/2014\/09\/Image1.jpg"},{"@type":"BreadcrumbList","@id":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2014\/09\/11\/linked-selection-fields-through-client-side-scripting\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/"},{"@type":"ListItem","position":2,"name":"Linked selection fields through client side scripting"}]},{"@type":"WebSite","@id":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/#website","url":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/","name":"Sage CRM \u2013 Tips, Tricks and Components","description":"Explore the possibilities with Sage CRM insights through our comprehensive blogs. As a leading Sage partner, Greytrix helps businesses maximize their Sage CRM potential with its rich expertise and immense knowledge. Here, you will find blogs that feature expert advice, tips &amp; tricks, best practices, and comprehensive guides on customizing and configuring Sage CRM for your business. Stay informed with our regular updates and expert insights!","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/#\/schema\/person\/e7ff1c8f4763b47730d6bc5e74d59c1f","name":"greysagecrm","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/c3b4325cb326e36467f945b9b9adf2bb85e907fe092d42eb36b39743b492e626?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/c3b4325cb326e36467f945b9b9adf2bb85e907fe092d42eb36b39743b492e626?s=96&d=mm&r=g","caption":"greysagecrm"},"url":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/author\/greysagecrm\/"}]}},"_links":{"self":[{"href":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-json\/wp\/v2\/posts\/8629","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-json\/wp\/v2\/comments?post=8629"}],"version-history":[{"count":1,"href":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-json\/wp\/v2\/posts\/8629\/revisions"}],"predecessor-version":[{"id":23405,"href":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-json\/wp\/v2\/posts\/8629\/revisions\/23405"}],"wp:attachment":[{"href":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-json\/wp\/v2\/media?parent=8629"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-json\/wp\/v2\/categories?post=8629"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-json\/wp\/v2\/tags?post=8629"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}