Help with some code

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • starling
    Confirmed User
    • Jan 2017
    • 312

    #1

    Help with some code

    This one should be quite simple but i'm struggling to get it right. I need a button with an input to take a number and store it into a domain. Like the ccbill thing you see where you put your number in and it will replace:
    whateverdomain.com/xxxxxxalidland
    to
    whateverdomain.com/123456alidland
    Ive tried javascript getElementByID but as i'm storing the button input as a variable it always comes up wrong I keep getting value="whatever" replacing the whole domain

    I know I could use php to echo a variable into the code but i'm not sure if this can be implemented into a wordpress page can it? Would I have to build a plugin?

    Any help would be appreciated
  • starling
    Confirmed User
    • Jan 2017
    • 312

    #2
    Code:
    <p>So this would be the paragraph and<span id="your_paragraph">THIS</span>is the word to be changed</p>
    INPUT HERE: <input type="text" id="theText" />
    <input type="button" id="btn" value="Update" />
    
    <script>
    var span = document.getElementById('your_paragraph');
    var btn = document.getElementById('btn');
    var txt = document.getElementById('theText');
    btn.onclick = function(){
        span.textContent = txt.value;
    };
    </script>
    The problem is it only works on one element instead of multiple. Is there a way to make it change all instances of the word to the same input, if I had multiple paragraphs?

    Comment

    • sarettah
      see you later, I'm gone
      • Oct 2002
      • 14297

      #3
      Originally posted by starling
      Code:
      <p>So this would be the paragraph and<span id="your_paragraph">THIS</span>is the word to be changed</p>
      INPUT HERE: <input type="text" id="theText" />
      <input type="button" id="btn" value="Update" />
      
      <script>
      var span = document.getElementById('your_paragraph');
      var btn = document.getElementById('btn');
      var txt = document.getElementById('theText');
      btn.onclick = function(){
          span.textContent = txt.value;
      };
      </script>
      The problem is it only works on one element instead of multiple. Is there a way to make it change all instances of the word to the same input, if I had multiple paragraphs?
      You would need to go through all elements that can contain the word to be replaced and replace each one individually I would think.

      .
      All cookies cleared!

      Comment

      • starling
        Confirmed User
        • Jan 2017
        • 312

        #4
        Originally posted by sarettah
        You would need to go through all elements that can contain the word to be replaced and replace each one individually I would think.

        .
        I managed to get it with a jquery find/replace code thank you

        Comment

        • Barry-xlovecam
          It's 42
          • Jun 2010
          • 18083

          #5
          What is the purpose? Hide the affiliate links?
          Googlebot has been proven to read and execute JavaScript now -- if that is the purpose it is a waste of time.

          This may work for inserting php code -- not an endorsement -- use at your own risk.
          https://adinserter.pro/about

          Comment

          • starling
            Confirmed User
            • Jan 2017
            • 312

            #6
            Originally posted by Barry-xlovecam
            What is the purpose? Hide the affiliate links?
            Googlebot has been proven to read and execute JavaScript now -- if that is the purpose it is a waste of time.

            This may work for inserting php code -- not an endorsement -- use at your own risk.
            https://adinserter.pro/about
            I'm making a backend for affiliates, I'll give it a look.

            Comment

            • TACNet
              Confirmed User
              • Jan 2009
              • 452

              #7
              Originally posted by Barry-xlovecam
              Googlebot has been proven to read and execute JavaScript now
              Hi

              Is that true ? Ive often wondered

              Sorry off topic i know


              TAC Amateurs - The World's LARGEST Amateur Porn Network

              Comment

              • Barry-xlovecam
                It's 42
                • Jun 2010
                • 18083

                #8
                Originally posted by TACNet
                Hi

                Is that true ? Ive often wondered

                Sorry off topic i know
                Thats what I have read at the big SEO sites -- they did tests.

                My old JS 'you better have my cookie' script was detected by Google and all of those pages ended up delisted (I think so) a couple of years ago when this news was disclosed. Harder to run googlebot in circles these days. Time to develop anti-googlebot warfare and lots of cheap new gTLD domains on cloud VPS servers that will have new ips. Today most big hosts are multinational with multi IP 'A - B' blocks -- problem is the AS blocks (ASN) are assigned to the Hosting Co.

                So does Google check AS blocks now? IDK.

                Comment

                Working...