Is it possible to execute the value of an HTML textbox? [duplicate] - javascript

This question already has answers here:
How to pass text in a textbox to JavaScript function?
(7 answers)
Closed 2 years ago.
I'm trying to create something that allows people to execute a line of JS. I want to convert the string that people type into a function to execute on the page using the HTML tag
I've looked around and nothing is helping to this.

you can use eval();
example :
eval("console.log('hello')");

Related

Is there a better alternative to slice? [duplicate]

This question already has answers here:
Parse query string in JavaScript [duplicate]
(11 answers)
How can I get query string values in JavaScript?
(73 answers)
Closed 9 months ago.
I'm kind of new to javascript and I was wondering if there was a better alternative to slice. I'm currently using window.location.slice at the moment and it feels like I could be using a better alternative. If you've ever used express.js you might have heard of "req.query.id", something like that in raw javascript would be perfect. Thanks, Alek.

Convert JS variable to JSTL [duplicate]

This question already has answers here:
Call Servlet and invoke Java code from JavaScript along with parameters
(3 answers)
Closed 5 years ago.
I have a javascript variable. I'd like to assign the value of it to JSTL variable.
How can I achieve it?
This is not possible since JavaScript is run in the client browser and JSTL in the server.
Your JavaScript must send the value to a servlet, one way or another.

Get JavaScript File Name? [duplicate]

This question already has answers here:
How might I get the script filename from within that script?
(12 answers)
Closed 8 years ago.
Is there any way to get its filename by only using javascript?
For example
I want to get the string somefile.js?v=32&b=2.2 inside that same javascript file.
Is it possible to get it without going through the script tag?
Filename using only for loading script text. After that this script text puts in javascript tag and executes.

PHP $_GET in plain html/javascript [duplicate]

This question already has answers here:
How can I get query string values in JavaScript?
(73 answers)
Closed 8 years ago.
I am trying to figure out how to get the parts of a URL I am going to be receiving from a third-party website. The URL I am expecting is something like: index.html?lob=company&ZipCode=22407
All of my pages are coded in .html rather than PHP due to my client's needs/desires, so my question is how can I get the "ZipCode" value.
In PHP this would be super simple, however I cannot do that.
Use Javascript instead.
var value_of_zipcode = "index.html?lob=company&ZipCode=22407".match("ZipCode=([0-9]{5})")[1];
now the value_of_zipcode is 22407

how to check calling function in jquery [duplicate]

This question already has answers here:
How do you find out the caller function in JavaScript?
(36 answers)
Closed 9 years ago.
I have a common error function which is called from many places. I want to know from which function this was called. Is there any way to do it?
In any javascript function you can use
arguments.callee.caller
if You want to execute JS in chrome you have to do like this
go to console and type your JS and enter!

Categories

Resources