0

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;
   }
1
  • 1
    have you tried document.getElementById('order_IDsearch').value, or if using jQuery $('order_IDsearch').val() ? Commented May 21, 2012 at 14:09

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

1 Comment

It works now, Thank you I have made a stupid mistake, I have define the var out side of the function();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.