Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change form labels on hosted page

Tags:

javascript

I am using Chargify to sell some subscriptions online.

They provided hosted pages where you can collect information that leads to the creation of a subscription and customer in their system.

Here's our form page here: https://exponential-finance.chargify.com/h/3373511/subscriptions/new

As you can see, we'd really like to have those fields labeled "Billing Address" instead of "Shipping Address."

Alas, there is no way within Chargify to change those labels. However, the DO provide the ability to load javascript on the page.

I understand that it is theoretically possible to change HTML on a page using a script.

I've spent a couple hours attempting some scripts found online, but none do the job.

Here's an example of a label that I want to change:

<p class="left">
  <label for="subscription_customer_attributes_address">*  Shipping Address 1</label><br />
  <input id="subscription_customer_attributes_address" name="subscription[customer_attributes]
[address]" size="30" type="text" />
</p>

Can somebody point me to a script that would allow me to change the label text from "Shipping" to "Billing" for this field, and even better, for any instance of the word "Shipping?

like image 803
Tom Elliott Avatar asked Dec 06 '25 10:12

Tom Elliott


1 Answers

<script>
  window.onload=function() {
   var lab = document.getElementsByTagName('label');
    for (i=0, l=lab.length;i<l;i++)
    {
     var old = lab[i].innerHTML;
     var news = old.replace(/shipping/i, 'Billing');
     document.getElementsByTagName('label')[i].innerHTML=news;
    }
  };
</script>

JSFiddle: http://jsfiddle.net/2YABH/3/

like image 146
loveNoHate Avatar answered Dec 08 '25 01:12

loveNoHate



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!