Welcome, Guest
  • Author Topic: problem passing checkbox value to php function using newWindow  (Read 2084 times)

    david007

    • Seasoned Programmer
    • ***
    • Posts: 127
      • View Profile
    Hi all. In the past i used the code below to pass multiple checkbox values to php script. Now when i try to only pass  one checkbox value at a time it failes. The window pops up with correct url but it never executes the php script!!! If i just hit f5 over popup window the php gets exetued. I be happy if some one help me fix this script to pass the check box corectly and execute the php. In the past it used to wrok fine for multiple values and i don't know what is wrong with it now.Thanks

    My php script only needs to grab the passed value using get method and then write it to db
    Code: [Select]
    <html>

    <body>



    <script language="javascript">
    <!-- hide
    var checkflag = "false";
    function check(field) {
    if (checkflag == "false") {
    for (i = 0; i < field.length; i++) {
    field[i].checked = true;}
    checkflag = "true";
    return "Uncheck All"; }
    else {
    for (i = 0; i < field.length; i++) {
    field[i].checked = false; }
    checkflag = "false";
    return "Check All"; }
    }

    function newWindow(url) {
    var x,y;
    x = screen.width-35;
    y = screen.height-30;
    var win = window.open(url,'glossaryWindow','toolbar=no,directories=no,width=500,height=500'+
    'screenX=0,screenY=0,top=0,left=0,location=no,status=no,scrollbars=no,resize=yes,menubar=no');


    // Start of Playme Function
    function playme()
    {
    totalvotes = document.forms.mp3Play.totalvotes;
    tempUrl ='';
    url = '';

    if (totalvotes.length > 0){ 
     for (i=0; i<totalvotes.length; ++ i)
     {
    if (totalvotes[i].checked)
    {
    tempUrl =tempUrl  + totalvotes[i].value +","
    if (i == 30)
    {
    alert("Each time you can only select 30 checkbox")
    return false;
    }
    }
     }
    }
    else
    {
    //alert("it is less than 0#2")
    tempUrl = totalvotes.value
             // tempUrl = "totalvotes=" + totalvotes.value
           

    }
    //alert(tempUrl);
    url = "../89370975/engage.php?sessionkey=" + tempUrl.replace(/,$/,"");

    newWindow(url);
    return false;
    }
    // End of Playme Function
    // -->
    </script>

    <form method="POST" action="../Members/List.php"  name="mp3Play">

     <table cellSpacing="0" cellPadding="0" width="900" border="0">
      <tr>
        <td width="900">
        <img height="6" src="./images/spacer.gif" width="10"></td>
      </tr>
      <tr>
        <td width="900">
        <table class="t_brown" cellSpacing="0" cellPadding="0" width="893" border="0">
          <tr>
            <td vAlign="center" align="middle" width="893"><span class="header_s">
            last </span></td>
          </tr>
          <tr>
            <td class="text_box" vAlign="top" bgColor="#ffffff" height="50" width="893">
            <div id="Last" style="width: 888; height: 39">
           

    <input type="checkbox" value="7fa7fd2d5b2c9d3f977e1a28570yaa12" name="totalvotes"><br>
    &nbsp;</div>
            </td>
          </tr>
        </table>
        </td>
      </tr>
      <tr>
        <td bgColor="#f8eed6" width="900">
       </td>
      </tr>
    </table>

    <td colspan=7>
                                <p align="center">
                                &nbsp;&nbsp;&nbsp;
                                <button id="playSelected" onclick="playme()">Play Selected</button>&nbsp;&nbsp; &nbsp;&nbsp;
                                </td>
      </tr>

    &nbsp;</form>


    </html>
    « Last Edit: 04/04/07, 23:35 by david007 »