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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:58:20+00:00 2026-06-03T07:58:20+00:00

Is it possible, if one has a javascript variable like this: var myVariable =

  • 0

Is it possible, if one has a javascript variable like this:

var myVariable = "alert('BAM! It works!');"

to send it to an html page that has a script tag in, in other words, looks like this:
<script id="theScriptTag"></script>

and by ‘sending’ I mean going like this in the Javascript file:

getElementById("theScriptTag").innerHTML = myVariable;

Now maybe people normally don’t do this. If there’s another way to get a Javascript variable to an HTML page please don’t hessitate to tell. It’s difficult for me to explain why I would like to do it like this, only that I need to do it like this.

Thanks in advance!

EDIT…

From all the comments I can see this is some serious bad practice. Let me give you the over view and ‘bigger picture’ here… On the very same HTML page there is a form, and a div. Now right after a user fills out the form and submits it, it goes to the server and ‘custom javascript’ is generated depending on the variable the user selected. This custom javascript is then intended to go back to the client and execute. When it executes is creates/fills up a div element that then contains a google charts table (thus needed to get generated server side). The JS that needs to be executed looks like this:

var sendAttemptsChartTableData, sendAttemptsChartTable; 
google.load('visualization', '1', {packages:['table']}) 
 google.setOnLoadCallback(drawTable); 
 function drawTable() { 
sendAttemptsChartTableData = new google.visualization.DataTable();  
sendAttemptsChartTableData.addColumn('string','smsGuid')  
sendAttemptsChartTableData.addColumn('string','attemptNo')  
sendAttemptsChartTableData.addColumn('string','response')  
sendAttemptsChartTableData.addColumn('string','error')  
sendAttemptsChartTableData.addRows(1)  
sendAttemptsChartTableData.setCell(0,0,'092A49AA-E2EF-46D3-A83E-0932B17B649A')  
sendAttemptsChartTableData.setCell(0,1,'1')  
sendAttemptsChartTableData.setCell(0,2,'<aatsms><submitresult action="enqueued"     key="2066317199" result="1" number="0833756610"/><submitresult action="enqueued" key="2066317200" result="1" number="0833756610"/><submitresult action="enqueued" key="2066317201" result="1" number="0833756610"/><submitresult action="enqueued" key="2066317202" result="1" number="0833756610"/></aatsms>')  
sendAttemptsChartTableData.setCell(0,3,'')  
sendAttemptsChartTable = new  google.visualization.Table(document.getElementById('sendAttemptsTable')); 
var view = new google.visualization.DataView(sendAttemptsChartTableData);   
sendAttemptsChartTable.draw(view, {showRowNumber: true, allowHtml:false}); 
google.visualization.events.addListener(sendAttemptsChartTable, 'select', smsSearchHandler); 
}  
  • 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-03T07:58:21+00:00Added an answer on June 3, 2026 at 7:58 am

    Based on your edit I understand your form sumbission results in a custom script. Would a JSONP-like solution work? Basically you can create a script tag in your current document, pointing its source to a server side script that processes the form and returns the code.

    A basic example:

    function getScript(){
      /**process form, generate params**/
      var nwScript = document.createElement('script');
      nwScript.src = '/myscriptsrc/somescript.php?'+[generated parameters];
      document.body.appendChild(nwScript);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

one question I always ask myself is how is it possible that javascript has
Is it possible to create an index that has as one of its columns
cgi.escape seems like one possible choice. Does it work well? Is there something that
Not sure if this is possible in one Makefile alone, but I was hoping
I'm not sure if this is possible in one mysql query so I might
I want to produce a simple, static HTML file, that has one or more
I have built a slider that has two possible buttons: one to .toggle ,
Possible Duplicate: Is there a best practice for generating html with javascript I want
I want to disable Javascript once a page has already loaded. Why? Because I
This question has been asked before for other languages: Python , PHP and JavaScript

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.