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.
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.
In line 23 of your JS, you set var tweet = quotesDisplay, but quotesDisplay is an id in your HTML, not a defined JS variable.
Oh wow thanks I see, how do I go about correcting it? Thanks
And also when I try any of the JS variables I get undefined error… Glad for any help
So, you are going to want to use document.getElementByI(“id you want the value of”) link instead of calling the function newVersetext.
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
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.
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!
Hey Tyler, this is great, its working now, only that its opening two windows. Any idea how to fix that?
Thanks
I went to your Codepen and tried it and only opened one window. Did you get it figured out?
Yes this is now sorted, i’m actually working on the Facebook one also Thank you so much man.