How can is set value in html element using php?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Aminul Islam
    New Member
    • Jul 2011
    • 1

    How can is set value in html element using php?

    sample code
    Code:
    <?php
    $userID = html text box value like "uid".
    without using GET or POST method
    because that method refresh page.
    
    my question is
    how can i set the value of html textbox name "uid"
    in the php variable $userid?
    
    ?>
    <script>
    function fun()
    { alert("<?php echo($userid) ;?>") }
    </script>
    <input type="text" id="uid">
    <input type="button" id="ok" onclick="fun()">
    Last edited by Niheel; Jul 28 '11, 06:28 PM.
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    PHP is executed before the content reaches the browser; it is a server-side language. If you just want to get the value of a textbox in the browser, javascript will do enable you to do that. I'll move this thread to the javascript forum so those guys can inform you how to do so.

    Comment

    • Rabbit
      Recognized Expert MVP
      • Jan 2007
      • 12517

      #3
      All you have to do is change your javascript function slightly.
      Code:
      function fun() {
         alert(document.getElementById("uid").Value)
      }

      Comment

      Working...