Posting quotes to twitter

Posting quotes to twitter
0.0 0

#1

Hi guys i need your help, i’m unable to target the quotes to display on my post tweet page, is there something i’m getting wrong? thanks

See the Pen My Verse Gen by Robbinson Omondi (@omoshx78) on CodePen.


#2

In line 23 of your JS, you set var tweet = quotesDisplay, but quotesDisplay is an id in your HTML, not a defined JS variable.


#3

Oh wow thanks I see, how do I go about correcting it? Thanks


#4

And also when I try any of the JS variables I get undefined error… Glad for any help


#5

So, you are going to want to use document.getElementByI(“id you want the value of”) link instead of calling the function newVersetext.


#6

Look at line 23 in the Javascript portion. The text now shows up in the ‘tweet’ text field, but i’m still figuring out why it doesn’t grab the current value of the ID. You need to make sure to update the ‘tweet’ variable whenever the ‘get new verse’ button is pressed, so that it matches the content of the quoteDisplay ID.

Sorry I’m not more helpful. Having a sick day and I’m a bit sluggish :slight_smile:


#7

Hey Tyler,

Thanks i can see the addition but still opening blank page, trying to crack my head around getting the data in vain. Sorry about your illness though you’ll be well.


#8

tweet = document.getElementById(‘quotesDisplay’).innerText;
^^^ you will want to put this in the function that updates to a new quote, so that whenever the quote is updated, the ‘tweet’ variable matches the text inside (you will also need to instantiate the ‘tweet’ variable using the default value, whether by hardcoding it in the Javascript, or by using the same as above outside of the ‘new quote’ function

https://twitter.com/intent/tweet?text=
^^^ then you can simply append the 'tweet ’ variable to this when you send the information to Twitter

I have a forked working copy saved on my Codepen, but hopefully the above is enough to puzzle through it. Cheers!


#9

Hey Tyler, this is great, its working now, only that its opening two windows. Any idea how to fix that?

Thanks


#10

I went to your Codepen and tried it and only opened one window. Did you get it figured out?


#11

Yes this is now sorted, i’m actually working on the Facebook one also :slight_smile: Thank you so much man.