<!DOCTYPE html> <html> <!-- Magnolia Carbone --> <!-- October 17, 2011 --> <!-- Chapter 8 - Page 474 --> <head> <title>New Items</title> <script type="text/javascript"> /* <![CDATA[ */ /* ]]> */ var newsItem1 = "L'AQUILA, ITALY (AP) - L'Aquila's chief prosecutor announced an investigation into allegations of shoddy construction as workers continued to scour the rubble for people still missing after a devestating earthquake five days ago. http://in.reuters.com/article/ idUSWBT01103020090411"; var newsItem2 = "WASHINGTON (Reuters) - President Barack Obama said on Friday the recession hit US economy was showing 'glimmers of hope' despite remaining under strain and promised to further steps in coming weeks to tackle the financial crisis. http://in.reuters.com/article/ idUSWBT01103020090411"; var newsItem3 = "(eWeek.com) - Apple is close to hitting 1 billion downloads from it's App Store and plans on a prize giveaway for whoever downloads the billionth application that includes a MacBook Pro and an iPod Touch. http://www.week.com/c/a/ Application-Developmen/eWeek-Newsbreak -April-13-2009/"; var newsItem4 = "ATLANTA (AP) - Chipper Jones drove in two runs, including a tiebreaking single, and the Atlanta Braves beat Washington 8-5 on Sunday to hand the Nationals their sixth straight loss to start the season. http://www.newsvine.com/_news/2009/04/11/2667835-jones-braves-beat-winless-nationals-8-5?catagory=sports"; </script> </head> <body> <form action="" name="newsHeadlines" method="get"> <table style="border: 0; width: 100%"> <tr valign="top"> <td> <select name="headline" multiple="multiple" style="height: 93px"> <option onclick="document.newsHeadlines .news.value=newsItem1"> Investigation of building standards in quake zone</option> <option onclick="document.newsHeadlines .news.value=newsItem2"> Obama sees signs of economic progress</option> <option onclick="document.newsHeadlines .news.value=newsItem3"> Apple App Downloads Approach 1 Billion</option> <option onclick="document.newsHeadlines .news.value=newsItem4"> Jones, Braves beat winless Nationals 8-5</option> </select> </td> <td> <textarea name="news" cols="50" rows"10" style="background-color: Transparent"></textarea> </td> </tr> </table> </form> </body> </html>
This is a mix of HTML/Javascript problem
Page 1 of 14 Replies - 527 Views - Last Post: 27 October 2011 - 03:59 PM
#1
This is a mix of HTML/Javascript problem
Posted 27 October 2011 - 02:36 PM
The entire class seems to have issues with this. I figured trying here might help me. This code is from the book. It told us where to put the code and how. Yet, it's not working. I was wondering if someone would mind taking a look at it and make sure i did not do something wrong. The code wording/spelling is on point. I am just guessing I placed an element somewhere it's not supposed to be. Thanks.
Replies To: This is a mix of HTML/Javascript problem
#2
Re: This is a mix of HTML/Javascript problem
Posted 27 October 2011 - 03:24 PM
First off, those symbols you have in line 10 should be placed right before the closing </script> tag.
This should help you out with that.
When the book tells you to write those lines of info for the variables, does it include little arrows like the one on your keyboard's enter key? If so, it's probably not telling you to hit enter, it's telling you to do the exact opposite(if it was anything like my old Javascript book).
Anyways, replace your variables with this and it should work:
Don't forget to take out that /* ]]> */ and put it before the ending </script> tag
This should help you out with that.
When the book tells you to write those lines of info for the variables, does it include little arrows like the one on your keyboard's enter key? If so, it's probably not telling you to hit enter, it's telling you to do the exact opposite(if it was anything like my old Javascript book).
Anyways, replace your variables with this and it should work:
var newsItem1 = "L\'AQUILA, ITALY (AP) - L\'Aquila'schief prosecutor announced an investigation into allegations of shoddy construction as workers continued to scour the rubble for people still missing after a devestating earthquake five days ago. http://in.reuters.com/article/idUSWBT01103020090411"; var newsItem2 = "WASHINGTON (Reuters) - President Barack Obama said on Friday the recession hit US economy was showing \'glimmers of hope\' despite remaining under strain and promised to further steps in coming weeks to tackle the financial crisis. http://in.reuters.com/article/ idUSWBT01103020090411"; var newsItem3 = "(eWeek.com) - Apple is close to hitting 1 billion downloads from it's App Store and plans on a prize giveaway for whoever downloads the billionth application that includes a MacBook Pro and an iPod Touch. http://www.week.com/c/a/ Application-Developmen/eWeek-Newsbreak -April-13-2009"; var newsItem4 = "ATLANTA (AP) - Chipper Jones drove in two runs, including a tiebreaking single, and the Atlanta Braves beat Washington 8-5 on Sunday to hand the Nationals their sixth straight loss to start the season. http://www.newsvine.com/_news/2009/04/11/2667835-jones-braves-beat-winless-nationals-8-5?catagory=sports";
Don't forget to take out that /* ]]> */ and put it before the ending </script> tag
#3
Re: This is a mix of HTML/Javascript problem
Posted 27 October 2011 - 03:44 PM
Yes, it has the 'enter' arrows. I was wondering about that. The link doesn't seem to show up correctly. I will try the suggestions and get back with you. Thank you!
#4
Re: This is a mix of HTML/Javascript problem
Posted 27 October 2011 - 03:54 PM
Current Code:
Still not working. Am I STILL doing it wrong?
<!DOCTYPE html> <html> <!-- Magnolia Carbone --> <!-- October 17, 2011 --> <!-- Chapter 8 - Page 474 --> <head> <title>New Items</title> <script type="text/javascript"> var newsItem1 = "L'AQUILA, ITALY (AP) - L'Aquila's chief prosecutor announced an investigation into allegations of shoddy construction as workers continued to scour the rubble for people still missing after a devestating earthquake five days ago. http://in.reuters.com/article/idUSWBT01103020090411"; var newsItem2 = "WASHINGTON (Reuters) - President Barack Obama said on Friday the recession hit US economy was showing 'glimmers of hope' despite remaining under strain and promised to further steps in coming weeks to tackle the financial crisis. http://in.reuters.com/article/idUSWBT01103020090411"; var newsItem3 = "(eWeek.com) - Apple is close to hitting 1 billion downloads from it's App Store and plans on a prize giveaway for whoever downloads the billionth application that includes a MacBook Pro and an iPod Touch. http://www.week.com/c/a/Application-Developmen/eWeek-Newsbreak-April-13-2009/"; var newsItem4 = "ATLANTA (AP) - Chipper Jones drove in two runs, including a tiebreaking single, and the Atlanta Braves beat Washington 8-5 on Sunday to hand the Nationals their sixth straight loss to start the season. http://www.newsvine.com/_news/2009/04/11/2667835-jones-braves-beat-winless-nationals-8-5?catagory=sports"; /* <![CDATA[ */ /* ]]> */ </script> </head> <body> <form action="" name="newsHeadlines" method="get"> <table style="border: 0; width: 100%"> <tr valign="top"> <td> <select name="headline" multiple="multiple" style="height: 93px"> <option onclick="document.newsHeadlines.news.value=newsItem1"> Investigation of building standards in quake zone</option> <option onclick="document.newsHeadlines.news.value=newsItem2"> Obama sees signs of economic progress</option> <option onclick="document.newsHeadlines.news.value=newsItem3"> Apple App Downloads Approach 1 Billion</option> <option onclick="document.newsHeadlines .news.value=newsItem4"> Jones, Braves beat winless Nationals 8-5</option> </select> </td> <td> <textarea name="news" cols="50" rows"10" style="background-color: Transparent"></textarea> </td> </tr> </table> </form> </body> </html>
Still not working. Am I STILL doing it wrong?
#5
Re: This is a mix of HTML/Javascript problem
Posted 27 October 2011 - 03:59 PM
If you mean the links aren't blue / clickable, it's because you need to add the <a> (anchor) tags. Javascript doesn't know they're links, although they have the syntax of one, since pretty much any type of information can be stored within a variable.
Ex. For the first link at the end of the first variable, replace:
With:
Don't forget the escape sequences!! Those are the backwards slashes just before the double quotes " in the <a> tag. This tells Javascript that the double quote should be included in the variable, and does not mark the end of the variable's information.
(blah idk if I'm just not seeing the editor or you can't edit messages, so if this shows as a double post, read it like an edit)
I forgot to say I also added two escape sequences (the backslashes before the two single quotes ' in the first variable). Notice how, if you're using a text editor such as jEdit or Notepad++, including/excluding those two single quotes changes the way text is colored? That means the text editor is interpreting your code differently. The 'var', the variable's name, and the information inside the quotes "" should all 3 be different colors if you use Notepad++ like I do.
Anyways, just copy the few lines I originally posted if you're having trouble locating the escape sequences.
-Sho Ke
Ex. For the first link at the end of the first variable, replace:
http://in.reuters.com/article/idUSWBT01103020090411
With:
<a href=\"http://in.reuters.com/article/idUSWBT01103020090411\">http://in.reuters.com/article/idUSWBT01103020090411 </a>
Don't forget the escape sequences!! Those are the backwards slashes just before the double quotes " in the <a> tag. This tells Javascript that the double quote should be included in the variable, and does not mark the end of the variable's information.
(blah idk if I'm just not seeing the editor or you can't edit messages, so if this shows as a double post, read it like an edit)
I forgot to say I also added two escape sequences (the backslashes before the two single quotes ' in the first variable). Notice how, if you're using a text editor such as jEdit or Notepad++, including/excluding those two single quotes changes the way text is colored? That means the text editor is interpreting your code differently. The 'var', the variable's name, and the information inside the quotes "" should all 3 be different colors if you use Notepad++ like I do.
Anyways, just copy the few lines I originally posted if you're having trouble locating the escape sequences.
-Sho Ke
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote




|