Jump to content
  • 0

Dynamically get the URL to reset parameter


FinTheHuman

Question

Hello,

I have a reset button for my search that I always placed on my search and report datapage. see below:

<input onclick="window.location='https://c1abc123.caspio.com/dp/55555000044441deb42123456789?cbResetParam=1'" type="button" value="Search reset" />

However it was so hassle if I re-create this in every search and report datapage I created. Then I found out that I can use "App Parameter" to use on my datapages which is good. 

My problem is how can I dynamically grab the page's URL to use on my onclick reset parameter?

Thank you for your help!

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

Hi @FinTheHuman,

You can try using this code for getting the current URL where the button is located:

<input class="cbSearchButton" style="background-color: #da2c2c !important;" onclick="window.location = window.location.href+'?cbResetParam=1'"
type="button" value="Reset" />

Sample URL: https://c1abv183.caspio.com/dp/482760000b3b87d609414355af13

You may refer here: https://www.w3schools.com/js/js_window_location.asp

I hope this helps :) 

Link to comment
Share on other sites

  • 0

Hello @FinTheHuman,

You can add this code in order to have one "?cbResetParam=1" on the URL :

Add on the Footer:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>

<script type="text/javascript">
$('#BUTTONIDHERE').click(function(){
var reset = $(location).attr('href').includes("cbResetParam=1");
if(reset == true){
location.reload();
} });
</script>

Then on your button add an ID that you will use on the code above (on this part: $('#BUTTONIDHERE') ):
image.png.1a982ffdc0fbf05733f272947e2980bd.png

Sample URL: https://c1abv183.caspio.com/dp/482760000b3b87d609414355af13

I hope this helps :) 

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