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 9122471
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:06:44+00:00 2026-06-17T06:06:44+00:00

So I built randomizing script that prints random numbers from 1 through twenty. And

  • 0

So I built randomizing script that prints random numbers from 1 through twenty. And those are all css classes that are in my css file. So here is what I want to do.

I want to have javascript print out the random number in this header id="" and

<!-- This is my js file -->
<script type="text/javascript" src="/assets/quotes.js"></script>

<!-- This is what I want -->
<header id="<script>showClass();</script>">

This is my js code:

var Classes=new Array()

Classes[0] = "one";
Classes[1] = "two";
Classes[2] = "three";
Classes[3] = "four";
Classes[4] = "five";
Classes[5] = "six";
Classes[6] = "seven";
Classes[7] = "eight";
Classes[8] = "nine";
Classes[9] = "ten";
Classes[10] = "eleven";
Classes[11] = "twelve";
Classes[12] = "thirteen";
Classes[13] = "fourteen";
Classes[14] = "fifteen";
Classes[15] = "sixteen";
Classes[16] = "seventeen";
Classes[17] = "eighteen";
Classes[18] = "nineteen";
Classes[19] = "twenty";
Classes[20] = "green";


var Q = Classes.length;
var whichClass=Math.round(Math.random()*(Q-1));
function showClass(){document.write(Classes[whichClass]);}
var random =document.getElementById('random').innerHTML="showClass()";

How can I make it so that the javascript renders in the id=""

  • 1 1 Answer
  • 0 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-06-17T06:06:45+00:00Added an answer on June 17, 2026 at 6:06 am

    The JS won’t render in the quotes as that is just a string. Instead do something like:

    <script type="text/javascript">
       document.write("<header id=\"");
       showClass();
       document.write("\">");
    </script>
    

    Personally, I’d prefer to add the element in an onLoad handler as roXon suggests but I think the above should drop in to what you have.

    Edited to match question revisions.

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

Sidebar

Related Questions

I built a quick program that needed to loop through an enormous log file
I built a script that downloads all the attachments in a particular outlook inbox,
Built an iPhone app that generates a random number to a label when a
I built an iPhone app that is getting information from a server (this is
Built a theme in HTML/CSS and customized a the cycle plugin to be a
Ive built a little jquery sliding div on my website that when you hover
I built a linear layout inside of a dialog , the problem here that
I built the following query: SELECT GVA14.COD_ZONA, Sum(GVA12.IMPORTE) AS SumOfIMPORTE FROM GVA14 LEFT JOIN
I built an App with the CorePlot framework for iPhone. I implemented 3 classes
I built a camera app. My problem is that I want to continue the

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.