Results 1 to 3 of 3

Thread: Problem of commas in the string?

  1. #1
    Join Date
    Mar 2007
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Problem of commas in the string?

    Hi all.
    I read data from DB and bind it with the onclick event of "carryvalue" function.
    When the commas in the data string, my carryvalue function can't work. Is any method to avoid it without chaning my DB data string?

    <script type="text/javascript">
    function carryvalue(v01, v02){
    document.getElementById('f01').value=v01;
    document.getElementById('f02').value=v02;
    }
    </script>

    </head>
    <body>


    <?
    //some php code
    for($i=$start;$i<$end;$i++){
    echo' <tr onclick="carryvalue('."'".$record[$i][1]."','".$record[$i][2]."'".');"> ';
    echo' <td class="c1">'.$record[$i][1]."</td> ";
    echo' <td class="c2">'.$record[$i][2]."</td> ";
    echo" </tr> ";
    }
    ?>
    <form action="aa.php" OnSubmit="return isEmpty(this)" method="POST" name="myform">
    <table>
    <tr>
    <td class="mylabel" width="100">GroupID:</td>
    <td><input type="text" name="VFGROUPID" size="80" id="f01" maxlength="8"></td>

    </tr>
    <tr>
    <td class="mylabel" width="100">GroupName:</td>
    <td>
    <input type="text" name="VFGROUPNAME" size="80" id="f02" maxlength="30" />
    </td>
    </tr>
    <tr>
    <td colspan="2" style="text-align: center"><input type="reset" value="Reset">
    <input type="submit" value="Save" name="FSAVE">
    <input type="submit" value="Delete" name="FDEL"></td>
    </tr>
    </table>
    </form>
    </body>

  2. #2
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,627
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Default

    Try the following code line

    Code:
    echo '<tr onclick="carryvalue(\''.$record[$i][1].'\',\''.$record[$i][2].'\');">';

  3. #3
    Join Date
    Mar 2007
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I try the code, but it seems not work ><"

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •