473,396 Members | 1,914 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

change content of div when the value input field is changed

194 100+
Hi everybody,

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
  1. <?php 
  2.  if($_POST['cbl']<>""){
  3. extract($_POST);              
  4. foreach($_POST['cbl'] as $k => $c){
  5. $k=str_replace("'","",$k);
  6. $k=str_replace("\\","",$k);
  7. $sql = "SELECT * FROM ".$GLOBALS['pre_tbl']."sometable WHERE id=".$k;
  8. $getAuto = mysql_query($sql); 
  9. $getAutoResultView = mysql_fetch_array($getAuto);
  10. $membal = soemfunction($getAutoResultView['id']);
  11. mysql_query($sql) OR die ("The query:<br>" . $sql . "<br>Caused the following error:<br>" . mysql_error());
  12.             ?>
  13.           <tr class="BalanceCells" onmouseover="style.backgroundColor='#f7f7f7';" onmouseout="style.backgroundColor='#dfdfdf';">
  14.             <td class="BalanceCells">
  15.             <input type="hidden" name="autoview['<?php echo $getAutoResultView['id']; ?>']" value="<?php echo $getAutoResultView['id']; ?>"  id="autoview">
  16.            <?= $getAutoResultView['id'] ?></td>
  17.             <td class="BalanceCells"><?= $getAutoResultView['name'] ?></td>
  18.             <td class="BalanceCells">
  19.              <?= $getAutoResultView['ba'] ?></td>
  20.             <td class="BalanceCells"><?= $getAutoResultView['no'] ?></td>
  21.             <td class="BalanceCells"><?= $CurrencySymbol.number_format($getAutoResultView['dwee'],2) ?></td>
  22.             <div id="bal-<?= $getAutoResultView['id']; ?>"><?= $membal['dwl'] ?></div>
  23.             <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>
  24.           </tr>
  25.  
  26.           <?php 
  27.           } 
  28.           }?>
  29.  
im trying to make function when i change the value of input field name ded then checkChange function will be called and it will change the value inside div anmed bal-some id(which will be generated dynamically through php). im not very much expert with the javascript but i made some function which is not giving me the value which falls inside the div. and can i use document.getElementById('name'+id).value?? or something else. im using the following code:

Expand|Select|Wrap|Line Numbers
  1.  
  2. function checkChange(id,value){
  3. var a = document.getElementById('bal'+id);
  4. alert(a);
  5. }
  6.  
  7.  
Please ignore any php error cuz its working fine with me.
now this funciton says a is null. please help me. thanx
Mar 27 '10 #1
4 5960
RamananKalirajan
608 512MB
Hi,
Please check this line.
Expand|Select|Wrap|Line Numbers
  1. <div id="bal-<?= $getAutoResultView['id']; ?>">
there is a '-' after the string 'bal'

Thanks and Regards
Ramanan Kalirajan
Mar 27 '10 #2
mfaisalwarraich
194 100+
thanx for ur quick reply. but it has now something [object HTMLDivElement] means its working. but the problem is same as im not able to get the content of the div.
Mar 27 '10 #3
Dormilich
8,658 Expert Mod 8TB
document.getElementById() returns a reference to the DOM-Element. getting the content actually depends on what’s inside the div. you can use .textContent (all the text in the div), .innerHTML (the HTML code in the div), .firstChild.data (text of the first node (… if it’s a text node)), etc.
Mar 27 '10 #4
mfaisalwarraich
194 100+
thanx dormilich for your help.
Mar 30 '10 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Matt Herson | last post by:
I have been trying to find a way to use JavaScript to change the value of a hidden field on submit. I am already invoking a JavaScript to handle the validation on submit. The reason I need to...
4
by: Richard Cornford | last post by:
For the last couple of months I have been trying to get the next round of updates to the FAQ underway and been being thwarted by a heavy workload (the project I am working on has to be finished an...
4
by: N. Graves | last post by:
Hello... thank you for your time. I have a form that has a List box of equipotent records and a sub form that will show the data of the equipment select from the list box. Is it possible to...
4
by: Roger | last post by:
I have a datagrid and would like to know what even fires when a cell is changed? I want to know when the user changes a cell and moves to the next. I have some code that needs to be done to...
3
by: Bundy | last post by:
Hi How do I change the background colour of an input box in a form as soon as the value is changed? Also the background should revert back to it's original colour if the user decides that they...
5
by: raha | last post by:
hi. Is there any body to help me? I am writing a web program. I have some forms. each form have some controls and users can edit the controls. finally they can save their forms. I would like...
2
by: bucchi | last post by:
Hi, I have an input field and I have to change the background color when the contents change. The contents are changed by a pop-up. On submit of the pop-up the contents change.How can I...
5
by: =?Utf-8?B?Y2hlY2tyYWlzZXJAY29tbXVuaXR5Lm5vc3BhbQ== | last post by:
I have a VS 2008 ASP.NET webform that has a reportview tag on it, accessing an .RLDC report in local report. The columns for the report are essentially: Month Item #1 Item#2 Item#3 ...
0
by: Czechtim | last post by:
Hello, I have problem with databinding. I created small application using structure that I need to demonstrate problem. I need to change content of label when changing content of property...
5
by: thatcollegeguy | last post by:
Below are my 3php and 2js files. I create a table using ajax/php and then want to change the values in the tables add(+ number for teamid) id's for each specific td in the table. I don't know...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.