Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
I have a function that returns value in "data"

C#
var successF = function (data) {
       
     var  eventID = data;
      
       var url = '/Admin/AddEvent.aspx?eventID=' + data;
     
       window.location.href = url;
   }


When I hover over url, it shows me url=:

JavaScript
/Admin/AddEvent.aspx?eventID=[Object Object]


how can I get the eventID show the real value?
Posted

1 solution

If you have no option to use server-side programming, such as PHP, you could use the query string, or GET parameters.

In the form, add a method="GET"

JavaScript
<form action="display.html" method="GET">
    <input type=""text"" name=""serialNumber"" />
    <input type=""submit"" value=""Submit"" />
</form>


When they submit this form, the user will be directed to an address which includes the serialNumber value as a parameter. Something like:

http://www.example.com/display.html?serialNumber=XYZ

You should then be able to parse the query string - which will contain the serialNumber parameter value - from JavaScript, using the window.location.search value:

// from display.html
document.getElementById("write").innerHTML = window.location.search; // you will have to parse // the query string to extract the // parameter you need
 
Share this answer
 

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