Note that there are some explanatory texts on larger screens.

plurals
  1. POJS: Displaying html w/ variables via document.write
    primarykey
    data
    text
    <p>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 <strong>understand</strong> why this is happening.</p> <p>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.</p> <p>At the moment, I'm getting the prompts, but after I enter data into the third box and submit it, nothing happens. </p> <p>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?</p> <p>Thanks!..</p> <pre><code>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("&lt;a style=\"color: #777777\" href=\"http:\/\/site_url\" title=\"site_title\"&gt;site_title&lt;\/a&gt;"); } else if (site_type = video) { document.write("&lt;a style=\"color:#98B2C3\" href=\"http:\/\/site_url\" title=\"site_title\"&gt;site_title&lt;\/a&gt;"); } else if (site_type = image) { document.write("&lt;a style=\"color:#8D5359\" href=\"http:\/\/site_url\" title=\"site_title\"&gt;site_title&lt;\/a&gt;"); } else (site_type = article); { document.write("&lt;a style=\"color:#768D53\" href=\"http:\/\/site_url\" title=\"site_title\"&gt;site_title&lt;\/a&gt;"); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload