#1
  1. No Profile Picture
    The Sandman
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2001
    Location
    Ouderkerk, The Netherlands
    Posts
    46
    Rep Power
    13

    convert javascript to php


    How can I convert num to $num?

    PHP Code:
    <script language="JavaScript">
    function 
    submit_form(num){
    ...
    $num=
    }
    </script> 
    Thanx!
    Did I confuse you? I never ment to throw sand in your eyes.

    The Sandman
  2. #2
  3. No Profile Picture
    Senior Citizen
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jan 2001
    Location
    leftcoast
    Posts
    2,019
    Rep Power
    16
    <script language="JavaScript">
    function submit_form(num) {
    document.the_form.num = num;
    }
    </script>

    <form name="the_form">
    ............
    <input type="hidden" name="num">
    ............
    </form>
  4. #3
  5. No Profile Picture
    The Sandman
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2001
    Location
    Ouderkerk, The Netherlands
    Posts
    46
    Rep Power
    13
    This doesn't seem to work. Other suggestions?
    Did I confuse you? I never ment to throw sand in your eyes.

    The Sandman
  6. #4
  7. No Profile Picture
    Senior Citizen
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jan 2001
    Location
    leftcoast
    Posts
    2,019
    Rep Power
    16
    I took your question to mean: I want the value of a client-side variable named num to show up, upon form submission to php, as $num.

    You could hardly have given fewer details....doesn't seem to work...work how? What are you trying to do?
  8. #5
  9. No Profile Picture
    The Sandman
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2001
    Location
    Ouderkerk, The Netherlands
    Posts
    46
    Rep Power
    13
    I've got the following script:

    PHP Code:
    $i=1;
    while(
    $i<=$aantal_vragen && $view=="all"){
    print 
    "used time question $i$vers[$i]<br>";
            
    $q=mysql_query("select * from vragen where id='$id[$i]'");
                while(
    $r=mysql_fetch_array($q)){
                    
    $vraag=$r['vraag'];
                    print
    "
                    <td>
                      <input type=\"hidden\" name=\"p[
    $i]\" value=\"$dir/$vraag\">
                      <div align=\"center\"><a href=\"#\" onclick=\"javascript: submit_form(
    $i);\">Message $i</a></div>
                    </td>"
    ;
                }
    $i++;

    It displays 5 buttons at random and each button has an id called $i

    When I submit the form I want to use the $i to trigger an event, so I use this script:

    PHP Code:
    <script language="JavaScript">
    function 
    submit_form(num){
    document.overview.num num;
    document.overview.submit();
    //alert(num)
    }
    </script> 
    I want to change the num into $num so I can trigger the event.
    Did I confuse you? I never ment to throw sand in your eyes.

    The Sandman

IMN logo majestic logo threadwatch logo seochat tools logo