Pass the value in javascript

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • maheswaran
    New Member
    • Mar 2007
    • 190

    Pass the value in javascript

    Hi all,

    Its is an simple question, but for me it takes more than 2 hours.

    Just i want to pass the value using java script function

    See this

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <HEAD>
    <TITLE> New Document </TITLE>
    <META NAME="Generator" CONTENT="EditPlus">
    <META NAME="Author" CONTENT="">
    <META NAME="Keywords" CONTENT="">
    <META NAME="Description" CONTENT="">
    <script>
    function testfun()
    {
    var avar=document.mahes.test.value;
    document.mahes.action="testpage.php?testpass="+aa;
    document.mahes.submit;
    }
    </script>
    </HEAD>
    
    <BODY>
    <form name="mahes" id="mahes" method="get">
    <input type="text" name="test" >
    <input type="submit" name="submit" value="submit" onclick="testfun()">
    </form>
    </BODY>
    </HTML>


    but i got only

    http://localhost/test/testpage.php?te st=enteredval&s ubmit=submit

    That is if i have input box then only i can able to pass value of the inputbox

    But i want to be the url as like

    http://localhost/test/testpage.php?te stpass=its me

    tesspass is the my custom variable ...How i can get it...
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    You could have a hidden field.

    aa would not be defined in your code anyway.

    Comment

    • maheswaran
      New Member
      • Mar 2007
      • 190

      #3
      is there any way to pass the javascript value using my custom variable as like

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        If you have this hidden field:
        Code:
        <input type="hidden" name="testpass" value="value">
        this will be passed in the URL. Of course, you can set the value before submitting.

        One quick note: submit is not a function call. submit() is.

        Comment

        Working...