1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How to get the textbox value on the same asp page

Discussion in 'C#' started by diane.serajose, May 25, 2012.

  1. #1
    Hi All,
    SEMrush
    I'm working with ASP classic and i want to get the value of the textbox then insert it to my sql statement. I used RemId = document.getelementId("txtRem").value but it doesn't work.

    Here are the part of my code:

    anyone can help me please.

    Thanks.
     
    diane.serajose, May 25, 2012 IP
    SEMrush
  2. WeddiGo

    WeddiGo Greenhorn

    Messages:
    40
    Likes Received:
    2
    Best Answers:
    2
    Trophy Points:
    18
    #2
    you will have to use javascript for that, ASP code executes before the page is loaded so your code document.getelementId("txtRem").value is actually javascript and won't do anything in ASP.

    this is a common issue people have to get their head around what is server & client side...I'll try to explain:


    ASP is server side so when someone points their browser to an asp page the server hosting the page does:
    1. loads up the page in the memory and
    starts composing a pure HTML page
    2. as the servers trawls through the code each time it encounters <% %> it executes that code and if needed inserts bits in the HTML page
    3. the server then sends a pure HTML page back to the browser
    What that means is that the ASP code was all done BEFORE the browser sees the page and the life of ASP code has finished at that point. ASP or any other server side code (php etc) has no more interaction with the page.

    Javascript:

    Now, javascript is client side which means that javascript code is executed INSIDE the browser using the users computer not your server.
    Javascript code is run when the page is loaded in the browser...so, your server has executed your ASP code, built a HTML page, sent it to the browser and then any Javascript inside that page can start running.

    There are couple of ways to acomplish what you are looking for:

    1. you can use javascript to "submit" the page to itself and then capture the value of that field in ASP and re-draw the page (basically like submitting the form)

    2. use javascript to keep an eye on that text field and then call the ASP to fetch information from the server...that is called AJAX...this is probably the option you would fancy the most but it's quite complicated to explain here

     
    WeddiGo, Sep 22, 2012 IP