Classic ASP - Help getting hidden value

I have a hidden value on a page.

    <input type="hidden" name="noteId" id="noteId"/>

I can 'see' the value in the HTML.   Next I need to get that value to run a query.
But the following next line is always null


' Run query based on noteId HERE


Any ideas what I am 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.

Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
You have to submit a form to get request.form to work.    If the field and request.form are on the same page and nothing is submitted it will not work.

You can use javascript or jquery to get a value on the page without submitting a form.  Can you post your code or link to your sample?
JElsterAuthor Commented:
It's as simple as this...   How can I get the value in Jquery and pass it to the query below?

    <input type="hidden" name="noteId" id="noteId"/>

                   <!-- Get Current Note Record -->
                       if NOT(IsNull(request.form("noteId")) or request.form("noteId")="") then
                            strSql = "SELECT * FROM NOTES WHERE NOTEID = " + request.form("noteId")

Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
You can't do that directly with javascript/jquery.  I do see an issue with your if statement.

   if NOT(IsNull(request.form("noteId")) or request.form("noteId")="") then

should be

   if NOT(IsNull(request.form("noteId")) AND request.form("noteId")<>"") then

Is a form being submitted here? or do you need to use the value that is typed into   <input type="hidden" name="noteId" id="noteId"/>?  If that is the case, we need to use ajax where we use javascript/jquery to grab the value entered and submit to another asp page, grab the output and bring it to the current page or redirect to another.
JElsterAuthor Commented:
Any way put the noteID in a session using JS and just call  Session("noteID");
Big MontySenior Web Developer / CEO of Commented:
Any way put the noteID in a session using JS and just call  Session("noteID");

yes, but you still need to post the data back to the server. once an http page loads, all forms of communication are done, the exception being when you use ajax, which I'm not sure would be appropriate here

to do what you want, you have to SUBMIT the value back to the server as was mentioned previously. you're on the right track with your code, you just need to allow for the value of noteID to be set (how will the hidden variable noteID be set?). you could do something like this:

         '-- Get Current Note Record
       '-- changed your IF statement to this way as you cannot post NULL values, only blank values, so the original IF statement was redundant        
      if Len( Request.Form("noteID") ) > 0 then                       
            dim noteID: noteID = Request.Form("noteID")

            '-- make sure we have a valid value for noteID
            if noteID = "" or not isNumeric( noteID ) then noteID = 0

           strSql = "SELECT * FROM NOTES WHERE NOTEID = " & noteID

       end if

<form name="frm1" id="frm1" method="post" action="thisPage.asp" >
    <input type="hidden" name="noteId" id="noteId" value="12345" />
    <button type="submit">Submit Hidden Variable NoteID</submit>

Open in new window

this is a very simple page to show you how to do what you're asking. copy and paste this into an asp page, run it, and you'll see the button. Once you click it, you will see the sql with a noteID value of 12345, which is a value I hard-coded as an example.

Any questions, please let us know.

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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.