Jump to content

Query String Values JavaScript


Recommended Posts

I had this working with one table and one field, but now I have two tables and two fields. I tried fixing it, it didn't work. Tried reverting to the old one, and now that stopped working. So I am totally lost.

I have a web form. The form has a dropdown for where you can select a Job. I have a button inside of a html block in this form. First you select the job, then click the button. The Job is the parameter being sent through the URL. When clicked, a page will popup and display results of all records matching that Job. I am working with the fields Job, Ordering_Table_Test_Job, and Ordering_CompletedOrders_Job.

Here is the script I am working with and cannot get any records from. My view has 4 records inside of it. After checking, it looks like the query string values are being passed through the url however I still get no results. I have tried going back to just one parameter like before, and now it still says no results. So I feel I really messed something up.

<script>

var fieldName = "Job"; // The name of your table field.
var paramName = "Ordering_Table_Test_Job"; // The name of your parameter
var paramNameTwo = "Ordering_CompletedOrders_Job"; // second 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}?${paramNameTwo}=${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,width=500,height=500,scrollbars=no,dependent=no'); return false;
}

</script>

 

Link to comment
Share on other sites

I was able to get records to show up with one variable. However it is still finicky and showing some results for the wrong job. Here is the script.

<script>

var fieldName = "Job"; // The name of your table field.
var paramName = "Ordering_Table_Test_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,width=500,height=500,scrollbars=no,dependent=no'); return false;
}

</script>

 

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
Reply to this topic...

×   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...
 Share

×
×
  • Create New...