I have some problem so need some help. wat im trying to do is making a function which will change the value of a input field when the value of other input field is changed. im using onchage event which triggers when i left the input field which is ok.
im using PHP to get the values into the input fields:
Expand|Select|Wrap|Line Numbers
- <?php
- if($_POST['cbl']<>""){
- extract($_POST);
- foreach($_POST['cbl'] as $k => $c){
- $k=str_replace("'","",$k);
- $k=str_replace("\\","",$k);
- $sql = "SELECT * FROM ".$GLOBALS['pre_tbl']."sometable WHERE id=".$k;
- $getAuto = mysql_query($sql);
- $getAutoResultView = mysql_fetch_array($getAuto);
- $membal = soemfunction($getAutoResultView['id']);
- mysql_query($sql) OR die ("The query:<br>" . $sql . "<br>Caused the following error:<br>" . mysql_error());
- ?>
- <tr class="BalanceCells" onmouseover="style.backgroundColor='#f7f7f7';" onmouseout="style.backgroundColor='#dfdfdf';">
- <td class="BalanceCells">
- <input type="hidden" name="autoview['<?php echo $getAutoResultView['id']; ?>']" value="<?php echo $getAutoResultView['id']; ?>" id="autoview">
- <?= $getAutoResultView['id'] ?></td>
- <td class="BalanceCells"><?= $getAutoResultView['name'] ?></td>
- <td class="BalanceCells">
- <?= $getAutoResultView['ba'] ?></td>
- <td class="BalanceCells"><?= $getAutoResultView['no'] ?></td>
- <td class="BalanceCells"><?= $CurrencySymbol.number_format($getAutoResultView['dwee'],2) ?></td>
- <div id="bal-<?= $getAutoResultView['id']; ?>"><?= $membal['dwl'] ?></div>
- <td class="BalanceCells"><input name="ded<?= $getAutoResultView['id']; ?>" type="text" value="<?= number_format($membal['we'],2) ?>" id="mytext-<?= echo $getAutoResultView['id']; ?>" onchange="checkChange(<?= echo $getAutoResultView['id']; ?>, this.value)" /></td>
- </tr>
- <?php
- }
- }?>
Expand|Select|Wrap|Line Numbers
- function checkChange(id,value){
- var a = document.getElementById('bal'+id);
- alert(a);
- }
now this funciton says a is null. please help me. thanx