User Inputted Text Fields

49 Views Asked by At

So what I am trying to do is when my team and I are in our salesforce program, I want the ability to click on a "Marklet" (javascript within a bookmark) that will automatically scan the source code of the page, find the "CID" section and grab whatever is within that text box (that is locked so it only changes when viewing another customer's salesforce page) and add it to the end of my url that will then search it within our MCC account.

Here is what I have got so far:

javascript:(onload=function MCC() {
var customer=document.getElementById("00N800000052k7r_ilecell");
if (customer != null) {document.getElementsByTagName('00N800000052k7r_ileinner').innerHTML 
    =window.open('https://adwords.google.com/mcm/Mcm?authuser=0&__u=6093584462&__c=2744111912#c.ac:s._'+encodeURIComponent(customer));}})();

Anytime I use this code, it pulls up the new tab and goes to the correct URL, but it always thinks I am searching for [object HTMLTableCellElement]. How do I correct this?

1

There are 1 best solutions below

3
On

getElementsByClassName returns an array, try:

document.getElementsByClassName('CID')[0]

or use an id and document.getElementById