Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 338401
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T10:25:33+00:00 2026-05-12T10:25:33+00:00

I just started learning JS the other day and am (of course) having some

  • 0

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>");
                }
}
  • 1 1 Answer
  • 3 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T10:25:34+00:00Added an answer on May 12, 2026 at 10:25 am

    Well, before we even start trying to work through how the if statements are going to work, we need to fix the fact that you are assigning not comparing in your if() statements.

    Rather than have a single = sign in your if statements you need to have 2 equal signs. Like this:

    if (site_type == website)
    

    A single = sign is used to assign variables, so in your case you’re actually assigning the value of website into the variable of site_type – not comparing the two seperate values.

    Try this:

    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>");
            }
            if (site_type == "video") {
                document.write("<a style=\"color:#98B2C3\" href=\"http:\/\/"+site_url+"\" title=\"site_title\">"+site_title+"<\/a>");
            }
            if (site_type == "image") {
                document.write("<a style=\"color:#8D5359\" href=\"http:\/\/"+site_url+"\" title=\"site_title\">"+site_title+"<\/a>");
            }
            if(site_type == "article") {
                document.write("<a style=\"color:#768D53\" href=\"http:\/\/"+site_url+"\" title=\"site_title\">"+site_title+"<\/a>");
            }
    }
    

    I’ve made a few changes to your code in the above chunk, not just removing the else statements. I’ve also made the if() comparisons check against strings rather than against empty variables as you had before and I’ve changed the document.write functions to use the added prompt strings in them.
    If we can get that to work, we can start thinking about where we really want to put the else statements at a later date 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just started learning C++ (coming from Java ) and am having some serious
I just started learning PHP and am having some trouble getting a simple login
I just started learning C but I don't understand this part of the code.
I´ve just started learning GWT and I´m trying to implement http://gwt.google.com/samples/Showcase/Showcase.html#!CwFileUpload and but failing
I just started learning about Kinect through some quick start videos and was trying
I just started learning some ruby, and I want to do something like this:
i just started learning assembly and making some custom loop for swapping two variables
I just started learning Drupal and I'm having a heck of a time displaying
I just started learning about domain driven design, and one of the few things
Just started learning algorithms. So the exercise is to find if statement is always/sometimes

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.