Passing parameter from HTML to javascript function

I am trying to pass a html control value to a javascript function.   My field is ifWOnumber, but when it opens the page the URL says


        function PrintThisPage(ord_no) {
            var sOption = "toolbar=yes,location=no,directories=yes,menubar=yes,";
            var ord = document.getElementById("ifWOnumber").value;
            sOption += "scrollbars=yes,width=750,height=600,left=100,top=25";
            var winprint ="CSSerialization_PrintWO.aspx?number=" + ord, "Print", sOption);


What am I doing wrong?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Assuming inline js

var ord = document.getElementById("<%= ifWOnumber.ClientID %>").value;
red_75116Author Commented:
The pop up window opens, but this is the URL on the page
If you view the page source what is the id of ifWOnumber - is it just ifWOnumber or some .net inspired ID
Exploring ASP.NET Core: Fundamentals

Learn to build web apps and services, IoT apps, and mobile backends by covering the fundamentals of ASP.NET Core and  exploring the core foundations for app libraries.

Miguel OzSoftware EngineerCommented:
Use UniqueID to get the required value:
var ord = document.getElementById("<%= ifWOnumber.UniqueID %>").value;

Your control's container is introducing prefixes thus the need for UniqueID to identify the control. This solution only works for inline JS not if the method is declared in a JS file.

Where is PrintThisPage called/declared?Inline?
red_75116Author Commented:
Using a custom control called inputfield and the id is ifWOnumber
The ID is generated at run time, you need to use

var ord = document.getElementById("<%= ifWOnumber.ClientID %>").value;


var ord = document.getElementById("ifWOnumber").value;

There is not ID of ifWOnumber when the html is generated.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.