how to pass javascript variable into php session

Discussion in 'PHP' started by goutam.dutta123, Oct 15, 2007.

  1. #1
    Hello Experts,

    I can not pass javascript variable into php session.
    My code:

    function keepID(myform)
    {
    i = 0, inputs = document.myform.getElementsByTagName('input');
    for(i=0;i<<?php echo $_SESSION['row'] ?>;i++)
    {
    if(document.myform.chkID.checked==true)
    {
    x=document.myform.chkID.value;

    }

    }
    }
    My checkboxes are moving in a loop:
    <input type="checkbox" name="chkID[]" id="chkID" value="<?=$rowSubjects['ID']?>" onClick="return keepID(this);">
    Please help...
     
    goutam.dutta123, Oct 15, 2007 IP
  2. Squash

    Squash Peon

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Can you click "View Souce" in web browser and look the JavaScript code that was generated after <?php echo $_SESSION['row'] ?> was done ? Does this php code was runned and any integer was passed into javascript code ?
     
    Squash, Oct 15, 2007 IP
  3. goutam.dutta123

    goutam.dutta123 Peon

    Messages:
    21
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I have clicked "View Souce" in web browser and look the JavaScript code that was generated after <?php echo $_SESSION['row'] ?>.This php code was runned and integer was passed into javascript code .
    Php variables are passing to javascript but dont know how to do vice versa.

    Thanks for your interest in it. Waiting for reply.
    Thank you.
     
    goutam.dutta123, Oct 15, 2007 IP
  4. Squash

    Squash Peon

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    So, if php expression was successfully replaced by integer - which problem do you have ?
     
    Squash, Oct 15, 2007 IP
  5. goutam.dutta123

    goutam.dutta123 Peon

    Messages:
    21
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thanks for the reply.

    function keepID(myform)
    {
    i = 0, inputs = document.myform.getElementsByTagName('input');
    for(i=0;i<<?php echo $_SESSION['row'] ?>;i++)
    {
    if(document.myform.chkID.checked==true)
    {
    x=document.myform.chkID.value;
    <?php $_SESSION['checkboxID'][$i] ?>=x;//My this line is not working
    }

    }
    }
    Please help..
     
    goutam.dutta123, Oct 16, 2007 IP
  6. Squash

    Squash Peon

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    So what you have in HTML on line, which is not working ?
     
    Squash, Oct 16, 2007 IP
  7. goutam.dutta123

    goutam.dutta123 Peon

    Messages:
    21
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Thanks for your patience..
    My checked check boxes will be remain checked in php pagination .The right ids are coming from db with onclick event .I want to keep these ids into session.When pages reloaded respective checkboxes will be checked.The javascript values are not going to session.
    Any idea or suggestion would be appreciated...
    function keepID(myform)
    {
    i = 0, inputs = document.myform.getElementsByTagName('input');
    for(i=0;i<<?php echo $_SESSION['row'] ?>;i++)
    {
    if(document.myform.chkID.checked==true)
    {
    x=document.myform.chkID.value;
    <?php $_SESSION['checkboxID'][$i] ?>=x;
    }

    }
    }
    Thanks again
    Please help..
     
    goutam.dutta123, Oct 16, 2007 IP