Jump to content
  • 0

Query String Values with Cascading Elements


kpcollier

Question

Hello.

I have a submission form with a popup link. The form has a Job dropdown element that is being used as a parameter to pass to the popup. When a Job is selected from the dropdown and the popup link is clicked, a List Report pops up and shows records related to the Job that was selected.

This works great. However, I need an element in the form to be cascading, and the Job dropdown has to be the parent field for this.

When I enable the cascading feature, my popup stops working. I get an Uncaught TypeError of null, stating that the parameter field name cannot be found. So, Job can be found before it is made a parent field for a cascading element, but once it is made the parent field, it stops working. 

Here is my code. 

<script>


var fieldName = "Job"; // The name of your table field.
var paramName = "Job"; // The name of your parameter


/* No modifications necessary beyond this line */

var inputField = document.querySelector('[action*="[@cbAppKey]"] #InsertRecord' + fieldName);
var linkToChild = document.querySelector('[action*="[@cbAppKey]"] #linkToChild');

var baseUrl = linkToChild.href; //do not touch
var moddedUrl = baseUrl; //do not touch

function updateLink() {
moddedUrl = `${baseUrl}?${paramName}=${this.value}`
}

['change', 'keydown','keyup'].forEach( function(e) {
    inputField.addEventListener(e, updateLink);
});

inputField.dispatchEvent(new Event('change'));


linkToChild.onclick = function() {
window.open(moddedUrl, '', 'resizable=no,status=no,location=no,toolbar=no,menubar=no,fullscreen=no,scrollbars=no,dependent=no'); return false;
}

</script>

Any help would be appreciated. This is maddening me, haha.

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

I am thinking that the code above is selecting the element by ID. I found out that when making an element cascading, it changes from a static_id to something that changes every time with a key appended to it (example_12fasf34gasd)

If I am selecting the element ID above, could someone show me where I can change it to find by name? I think this would fix it.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  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.

Loading...
×
×
  • Create New...