#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Posts
    2
    Rep Power
    0
    hi
    in an php form i want to take text filed value after cliking button(not submit button)
    so,in button onclick event its call javascript function.but i want to value of text filed in php script
    pl.help me

  2. #2
  3. .Net Developer
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    London
    Posts
    987
    Rep Power
    15
    [b]
    <<
    in an php form i want to take text filed value after cliking button(not submit button)
    so,in button onclick event its call javascript function.but i want to value of text filed in php script
    >>
    [b]

    Subramanian,

    you can do that..but why you are using with out a submit button..

    if you are using a java script for submitting your value to php then your program should be some thing like..

    <html>
    <head>
    <SCRIPT LANGUAGE="JavaScript">
    function submit(){
    document.formname.submit();
    //i am not sure about above function..
    // pls check it out in some java tutorial.
    }
    </SCRIPT>
    </head>
    <body>

    <form name="formname" action="test.php3">

    <input type="button" onClick="submit();">
    </form>
    </body>
    </html>

    ------ ----- ----- ----- ----- -----

    i would suggest you to use a submit button for submitting your form values to php program.becoz that would be safe other wise your javascript may give some problem in some old browsers..




    ------------------
    SR -
    webshiju.com

    "The fear of the LORD is the beginning of knowledge..."
  4. #3
  5. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Brussels, Belgium
    Posts
    14,648
    Rep Power
    4493
    You have to eventually submit the form, either by form.submit() or by using a submit button, to get the hidden values to php. a submit button is easy, or you could use the onsubmit= handler to call a function.
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
    //********
    //test.php
    //********
    <html>
    <head><title>Test Page</title>
    <script language="javascript">
    function test_me()
    {
    document.myform.hidden1.value='value1';
    document.myform.hidden2.value='value2';
    document.myform.hidden3.value='value3';
    }
    </script>
    </head>
    <body>
    <form method=post action=page3.php onsubmit="test_me();">
    <input type=text name="fname">
    <input type=text name="lname">
    <?php
    for ($count=1;$count<=3;$count++)
    {
    echo "<input type=hidden "name=hidden$count">
    }
    ?>
    <input type=submit name="submit" value="Submit Form">
    </body>
    </html>
    [/code]

    I just made that up, but hopefully it gives you some ideas. You can add if..then or while or whatever to the javascript function to do whatever you want to the form variable. say, maybe only make two hidden values if they don't give a first name...make 3 if they give both first and last, etc... it's up to whatever you are trying to do.

    you can always change the submit button to something else, and then add the document.myform.submit() line to test_me(), like Shiju recommended.



    ---John Holmes...

Similar Threads

  1. PHP scripts to run in Javascript continuously
    By linhardt in forum JavaScript Development
    Replies: 0
    Last Post: February 13th, 2004, 03:51 PM
  2. Need help with Javascript and fill a form
    By regisma in forum JavaScript Development
    Replies: 1
    Last Post: February 10th, 2004, 12:29 PM
  3. need help to fill a form with Javascript
    By regisma in forum JavaScript Development
    Replies: 1
    Last Post: February 10th, 2004, 12:19 PM
  4. javascript inside php tags
    By andy123 in forum JavaScript Development
    Replies: 5
    Last Post: February 5th, 2004, 05:34 PM
  5. HTTP Error 400: Bad Request, with basic form
    By crackwombat in forum PHP Development
    Replies: 1
    Last Post: January 23rd, 2004, 07:40 PM

IMN logo majestic logo threadwatch logo seochat tools logo