Hi. I have a javascript function to change the value of the cell on chnage event of a dropdown list.My code is workin but the problem is that the value of the cell is chaning but not respective to the selected dropdown list( as there are 15 dropdown list and 15 cells), but only on the 1st cell. So need some identification for each cell. Can anyone help me just refine my code. - <script type="text/javascript">
-
function displaytaskid(ths) {
-
var id= ths.options[ths.selectedIndex].value;
-
alert (id);
-
document.getElementById('task_id1').innerHTML=id;
-
}
-
</script>
- <?php for($count; $count <15; $count++)
-
{?>
-
-
<tr>
-
<td id ="task_id1[]"></td>
-
<td name = "task_id[]"><select name="task_id" id="dropdown" onchange="displaytaskid(this)">
-
<option value=""></option>5
-
<?php
-
-
while($lp_row = pg_fetch_assoc($res2))
-
{
-
$val = $lp_row["task_id"];
-
$caption = $lp_row["task_description"]; ?>
-
<option value="<?php echo $val ?>"><?php echo $caption ?></option>
-
<?php } ?></select>
-
</td>
16 4928
of course you have to give out unique ids to get it working.
Yeahh Dormi I know tht. But I really dnt knw how to change my code to do that.
what about - echo "<td id=\"task_id_$count\">";
?
besides, you don’t even have to use ids, since the select and the td have the same parent.
THanks Dormi, sounds a good idea.. but then how to identify it by the js function(what change I need to do to my JS function) to identify each cell with the respective change in the dropdown list
how much do you know about DOM?
(you have 2 td per tr?)
yes there are 2 td per tr.. In one td there is the cell where i want my value to be changed and in 2nd is the actual dropdown list. which is trigerrin the js function. A little bit about DOM. Whenevery this JS bit comes in my code i get confused as I m really not good at it.
Thanks vry much Dormi. This wud be really helpful. I know I really have to read this otherwise I ll keep on hanging around. But still rgt now if u have a solution for above do let me knw.
I have an idea. - parentNode.firstChild().nodeValue = this.value;
case closed*.
you need to know DOM to understand the meaning of that. and event listeners.
* – for me
and now for a working (FF) example - function setTD()
-
{
-
this.parentNode.parentNode.firstElementChild.textContent = this.value;
-
}
-
// addEventForEach() is a custom function
-
document.getElementsByTagName("select").addEventForEach("change", setTD, false);
I have changed my code to below.. but still dosnt work.?? does any one has a solution - <script type="text/javascript">
-
function displaytaskid(ths,rowno) {
-
var id= ths.options[ths.selectedIndex].value;
-
alert (id);
-
document.getElementById('task_id_rowno').innerHTML= id;
-
}
-
- <?php for($count; $count <15; $count++)
-
{?>
-
-
<tr>
-
<?php echo "<td id=\"task_id_$count\">"; ?>
-
<?php
-
$conn = connect();
-
$res2 = sql_select1();
-
?>
-
-
<td name = "task_id[]"><select name="task_id" id="dropdown" onchange="displaytaskid(this,\"$count\")">
-
<option value=""></option>5
-
<?php
-
-
while($lp_row = pg_fetch_assoc($res2))
-
{
-
$val = $lp_row["task_id"];
-
$caption = $lp_row["task_description"]; ?>
-
<option value="<?php echo $val ?>"><?php echo $caption ?></option>
-
<?php } ?></select>
-
</td>
-
JS, unlike PHP, does not search for variable names inside strings.
humm ok... I changed it to - document.getElementById(rowno).innerHTML= id;
but still no result
if rowno is not the ID then you have no target element.
note: can you see, how useful the DOM is?
Thanks Dormi...I got a way around passinf count variable was doin all the prob..Anyways thanks very much for ur help
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Lisa |
last post by:
I know this is supposed to be easy but I can't get this to work. I
have a dropdown that pulls all the Projects (tp_title) available. All
I want to do is get the ID (tp_id) of that record so I can...
|
by: DaveF |
last post by:
I need to capture a selected value of the onchange dropdown and put it in a
textbox???
--
Dave
|
by: David |
last post by:
Hi,
I have an asp page with a simple form.
The form has a dropdown which is database fed.
Once the user selects a value from the dropdown, I need some code to
test the value selected.
If...
|
by: =?Utf-8?B?QnJpYW5ESA==?= |
last post by:
Hi
I am trying to find a way to change the background color of a cell (flash or
blink) when its value has changed (by user or data update). I need to be
able to do this for more than one cell...
|
by: =?Utf-8?B?UGhpbCBKb2huc29u?= |
last post by:
Hi,
I need to have a column in a gridview that cycles through a set of comma
delimited values
i.e. if you imagine a column where in one row the value might be "111,222"
and in the next row it...
|
by: ghjk |
last post by:
I have a drop down box and the test box for the search field. In there I user only dropdown box to search values from the DB. But now I want to pass text box value with dropdownbox value. How can I...
|
by: Shreenath A |
last post by:
I am using two dropdown boxes in ASP. I want to pass the selected value of first dropdown to the QRY to fetch and display only those items which belongs to the first selected dropdown. I am using...
|
by: nawedita |
last post by:
Hi
I am facing a problem with my code ....
this is what I am doing ...
I am running this dropdown in while loop...and i want when i select Cheque then display textbox otherwise textbox not...
|
by: lipton |
last post by:
how can i compare a mysql table feild value with selected redio button value with php
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
| |