• 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!

TOPIC: Custom script for adding value via url

Custom script for adding value via url 9 years 9 months ago #31735

  • Crispin
  • Crispin's Avatar
  • OFFLINE
  • Senior Boarder
  • Posts: 75
  • Thank you received: 4
I need a script that will take the page title and add it, via the url, to a form.

Does any one know how to do this?

Crispin
The administrator has disabled public write access.

Custom script for adding value via url 9 years 9 months ago #31736

  • Crispin
  • Crispin's Avatar
  • OFFLINE
  • Senior Boarder
  • Posts: 75
  • Thank you received: 4
To clarify what I need

I will be adding a button that links to the form page at the bottom of an article page

I want to post a value to the form using the modified url method ?form=mail@domain.com[/b] I want a script that will take a value from the article, say the title, and add it to the above url value element.[email]=mail@domain.com

I want a script that will take a value from the article, say the title, and add it to the above url value element.
Last Edit: 9 years 9 months ago by Crispin. Reason: typo
The administrator has disabled public write access.

Custom script for adding value via url 9 years 9 months ago #31738

  • cosmin.cristea
  • cosmin.cristea's Avatar
  • OFFLINE
  • Platinum Boarder
  • Posts: 756
  • Thank you received: 144
Why would you need a script for this? Aren't you creating these buttons? If so, you have full control over the URL of the element and you do not need a script.
<a href="linktorsformpro?parameter&anotherparameter&anotherparameter">GO TO FORM</a>
My help is not official customer support. To receive your support, submit a ticket by clicking here
The administrator has disabled public write access.

Custom script for adding value via url 9 years 9 months ago #31740

  • Crispin
  • Crispin's Avatar
  • OFFLINE
  • Senior Boarder
  • Posts: 75
  • Thank you received: 4
Once everything is set up my client will be adding new pages using the initial one as a template. So I need to make it as simple as possible. Experience has shown anything that looks vaguely codey scares people even if it is simple.

If I were you are quite right, it wouldn't be a problem.
The administrator has disabled public write access.

Custom script for adding value via url 9 years 9 months ago #31741

  • cosmin.cristea
  • cosmin.cristea's Avatar
  • OFFLINE
  • Platinum Boarder
  • Posts: 756
  • Thank you received: 144
Although this is not bulletproof, it's a starting point to your needs (I wrote this in the bottom of the article):
<script>
// we get the article's title and trim the spaces surrounding it
var articleTitle = document.querySelector('[itemprop="name"]').textContent.trim();
 
// we grab the link (I added a link to the bottom of the article with the ID of 'formLink'
 
var link = document.getElementById('formLink');
 
// append to its href the syntax for adding a URL parameter
link.href += '?form[fieldname]='+articleTitle;
 
</script>

should work
My help is not official customer support. To receive your support, submit a ticket by clicking here
The administrator has disabled public write access.

Custom script for adding value via url 9 years 9 months ago #31742

  • Crispin
  • Crispin's Avatar
  • OFFLINE
  • Senior Boarder
  • Posts: 75
  • Thank you received: 4
Thank you, I will give that a go. Really appreciated.

I can see the logic.

Thank you again
The administrator has disabled public write access.

Custom script for adding value via url 9 years 9 months ago #31786

  • Crispin
  • Crispin's Avatar
  • OFFLINE
  • Senior Boarder
  • Posts: 75
  • Thank you received: 4
This works a treat.

Just as a note, the script has to come after the link. Probably obvious but it got me.

One more thing...

Is it possible to populate more than one field with this url method, even manually?
The administrator has disabled public write access.

Custom script for adding value via url 9 years 9 months ago #31788

  • cosmin.cristea
  • cosmin.cristea's Avatar
  • OFFLINE
  • Platinum Boarder
  • Posts: 756
  • Thank you received: 144
in my reply I told you that I inserted at the bottom of the article :)

as for your other question, the answer is yes.
// you can add here as many fields you want
link.href += '?form[fieldname]=value&form[otherfieldname]=value&form[someotherfieldname]=ft'+articleTitle;
My help is not official customer support. To receive your support, submit a ticket by clicking here
The administrator has disabled public write access.

Custom script for adding value via url 9 years 9 months ago #31791

  • Crispin
  • Crispin's Avatar
  • OFFLINE
  • Senior Boarder
  • Posts: 75
  • Thank you received: 4
Thanks

It all works very well thank you.

Take care
The administrator has disabled public write access.
  • 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!