PHP $_GET in plain html/javascript [duplicate] - javascript

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

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.

Is there any way to embed serverside JS into HTML (like PHP)? [duplicate]

This question already has answers here:
Node.js : How to embed Node.js into HTML?
(3 answers)
Closed 3 years ago.
Is there some way to embed node.js (i.e. server-side) code into HTML, like <?php does for PHP? What I'm aiming for is a pretty looking page, which will still have back-end functionality of whatever kind (say printing stuff from a database).
Thanks.
With node, you can use <?js tags
Hope this helps

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.

How to beautify xml received as string? [duplicate]

This question already has answers here:
Pretty printing XML with javascript
(22 answers)
Closed 8 years ago.
I have web service which returns xml as plain string. I need to format it like xml beautifier does. I expect it to be performed on client side by JavaScript. How can I do that? What libraries is better fitted for this task?
One way of doing it is to use "JavaScript code prettifier" from Google.
You can find it here: http://google-code-prettify.googlecode.com/svn/trunk/README.html.
Follow the setup guide in the link and include the javascript file and then use it like so:
prettyPrintOne(XML_TO_BEAUTIFIED, 'xml')

How to send form data in javascript? [duplicate]

This question already has answers here:
How to send data to remote server using Javascript
(3 answers)
Closed 8 years ago.
I am new to Javascript and html.
I need to send data through post method and like
{"username":"user1111","fileNumber":"20120097072286","fileType":"2"}
and read the response in Javascript.
If any one know the solution please help me.
You can do this using jquery AJAX like this:
$.post{
url:,
data:{},
success:function(){}
}

Categories

Resources