Click here to Skip to main content
15,891,828 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi could anyone please tell me how to pass an integer querystring value to a URL using javascript this is my first time im using java Script please guide me..
$(function () {
$("#sendmessage").click(function () {
//alert("Hi");
window.open("http://www.google.com?id=123");
)};

What I have tried:

$(function () {
$("#sendmessage").click(function () {
//alert("Hi");
window.open("http://www.google.com?id=123");
)};
Posted
Updated 26-Jun-16 23:05pm
v2
Comments
Karthik_Mahalingam 27-Jun-16 5:02am    
what is the issue ?
Aarthi.33 27-Jun-16 5:08am    
Hi im using
<input type="button" id="sendmessage" value="Send" />
on onclick function i need to pass the input value through a querystring to a URL using java script i'm complete new to this could you please guide me
Karthik_Mahalingam 27-Jun-16 5:13am    
check my solution.

1 solution

this should work

JavaScript
$(function () {
           $("#sendmessage").click(function (event) {
               var someValue = event.target.value;
               alert(someValue);
               var url = 'http://www.google.com?id=' + someValue;
               window.open(url);
           });
       });


HTML
<input type="button" id="sendmessage" value="Send" />
 
Share this answer
 
v3
Comments
Aarthi.33 27-Jun-16 5:15am    
thanks a lot :-) im doing this in SignalR client code where it needs to done in javascript could you please suggest whether windows.open is a good approach or can i go ahead with any other approach in passing the integer value through URL
Karthik_Mahalingam 27-Jun-16 5:20am    
Hi Aarthi
Query String is one of the ways of passing information to the server, if the data being passed in a not confidential then you shall use query string.
and also it depends how your application and business logic how it is designed, you will have to provide more information to give a possible answer.
Aarthi.33 27-Jun-16 5:20am    
And i need to send the value dynamically as the user gives the id value in the input textbox,we have hardcoded the value as of now..
Karthik_Mahalingam 27-Jun-16 5:25am    
then you shall use this
var someValue = $('#txtBoxId').val()
Aarthi.33 27-Jun-16 5:23am    
i need to send the employee id value through querystring in jvascript to a URL ,once the onclick function is triggered it opens a new window that belongs the URl and shows up all the details of the employee.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900