www.webdeveloper.com
Results 1 to 3 of 3

Thread: JavaScript access to Request.Form

  1. #1
    Join Date
    Aug 2013
    Posts
    1

    JavaScript access to Request.Form

    I'm quite new to JavaScript as a web development tool, so I hope this question is still OK.

    When a submit on a web page occurs the various form parameters are passed to the action program on the submitted form. (At least I think I have that right!) In VBscript these parameters values are available, for example, as "<%=Request("myText")%>".

    My question is, how to I gain access to these values in JavaScript in either the head or body of the page?

    I have put "var myText = Request.Form("myText");" into the head and referenced it with "<%=myText%>" in the body. But I get nothing.

    What am I missing?

    Thanks in advance.

    Joe

  2. #2
    Join Date
    Dec 2012
    Posts
    54
    I did something like this about 6 months back here is an example of the code I used

    the HTML:
    Code:
    <div id = "form" class = "form">
      <center>Sort Quantity: <input type = "text" id = "MaxNums" name = "Quantity"/>
      <button onclick = "ChangeMaxNumbers()">Change</button><br/></center>
      <div>
        <p>
          By changing the value above you can see the speed of a bubble sort become more inefficient as the maximum number becomes larger
          just try from 10 numbers to 100 and the speed is exponentially slower.  I wouldn't suggest more than 200 as it might be faster
          to sort by pen and paper!
        </p>
      </div>
    </div>
    the script was like this
    Code:
    function ChangeMaxNumbers(){
      MaxNumbers = document.getElementById("MaxNums").value; 
      if(MaxNumbers > 1000) 
        MaxNumbers = 1000;
      NumToHeightRatio = 195/MaxNumbers; 
      Reset();
    }
    You can see the working example at http://www.lesshardtofind.com/bubble.html

    In summary I added the function call into the html button click, and then in the function I grabbed the element by its ID and then used the ".value" variable.

    I hope this helps

  3. #3
    Join Date
    Dec 2012
    Posts
    54

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles