Hi all,
I just started learning JS the other day and am (of course) having some difficulty. I usually grasp onto things quickly but I can't for the life of my find a solution to this. I'd like to understand why this is happening.
My objective is to use 3 prompt boxes, all which come one after another, to print out a piece of html code, which will be a simple URL. I'll add more to this but I'd like to get past this first.
At the moment, I'm getting the prompts, but after I enter data into the third box and submit it, nothing happens.
What am I doing wrong here? If it's an error with my document.write code, what are some things I should be looking out for?
Thanks!..
function show_prompt()
{
var site_type = prompt("What kind of link is this?");
var site_url = prompt("What is the URL?");
var site_title = prompt("Give the link a title");
if (site_type = website) {
document.write("<a style=\"color: #777777\" href=\"http:\/\/site_url\" title=\"site_title\">site_title<\/a>");
}
else
if (site_type = video) {
document.write("<a style=\"color:#98B2C3\" href=\"http:\/\/site_url\" title=\"site_title\">site_title<\/a>");
}
else
if (site_type = image) {
document.write("<a style=\"color:#8D5359\" href=\"http:\/\/site_url\" title=\"site_title\">site_title<\/a>");
}
else
(site_type = article); {
document.write("<a style=\"color:#768D53\" href=\"http:\/\/site_url\" title=\"site_title\">site_title<\/a>");
}
}