Shahab Maboud
Shahab Maboud

Reputation: 45

value from HTML textbox to Javascript var

Hi want to store what user input into the textbox into my javascript var to be passed to my external PHP page,

I can pass the variable if i just define a value like mySite= 22 but not from what user enters into the text box.

Please help me to get access to the texbox.value

  <form method="post" action="" onsubmit="submitFun(this)">
  <input type="text" name="order_IDsearch" id="order_IDsearch"onBlur="javascript:setmysite(this);">

    <input type="submit" />

     </form> 



  <script type="text/javascript">


   var mySite = '';
   function setmysite(v1) {

   var parent = document.getElementById('list');
   var element = parent.GetElementsByTagName('order_IDsearch')[0];

   mySite = element;


   }

   function submitFun(f1) {

   t = './get_order.php?s=' + mySite;
   t = encodeURI (t);
   f1.action = t; 
   f1.submit();
   return true;
   }

Upvotes: 0

Views: 1971

Answers (1)

ZERO
ZERO

Reputation: 133

You can try document.getElementById('order_IDsearch').value;

Upvotes: 2

Related Questions