473,395 Members | 1,568 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,395 software developers and data experts.

Script Problem

rsrinivasan
221 100+
Hi,

Im creating dynamic Row in javascript. I did it. But now i want call some function, when i click that <td>. I do not know how to do it. Plz help me.

Thanks,
Srinivasan r.
May 18 '07 #1
21 1335
dmjpro
2,476 2GB
does not TD support onclick event firing?

plz try with this.
i think this ll work.
best of luck.

kind regards.
dmjpro.
May 18 '07 #2
rsrinivasan
221 100+
does not TD support onclick event firing?

plz try with this.
i think this ll work.
best of luck.

kind regards.
dmjpro.
Hi,
Then which event we can use for TD. OnClick event is worked, when im creating table staticaly. But i cant do it in script. Thats why im asking you.

Thanks,
Srinivasan r.
May 18 '07 #3
dmjpro
2,476 2GB
hmmmm .......

if anything wrong with my attitude can i get the dynamic row generation code and the function which u want to fire on clicking a TD?????

then i think i ll correct ur code.

kind regards.
dmjpro.
May 18 '07 #4
rsrinivasan
221 100+
hmmmm .......

if anything wrong with my attitude can i get the dynamic row generation code and the function which u want to fire on clicking a TD?????

then i think i ll correct ur code.

kind regards.
dmjpro.
This is the function to generate dynamic TD. I can set width and data. But i cant set event for this. I set Bold where i set the event.

function dealMenuDown()
{
document.getElementById('imgDeal').src='images/Deal_On.gif';
document.getElementById('imgSecurityAdmin').src='i mages/SecurityAdminOff.gif';

var myTable = document.getElementById('sub_table_id');
var myNewRow = document.getElementById('sub_row_id');

var dealLength = myNewRow.children.length;
for(i=0; i<dealLength; i++)
{
myNewRow.removeChild(myNewRow.lastChild);
}
var staticElem = document.createElement("TD");
staticElem.width = 120;
myNewRow.appendChild(staticElem);
for(i=0;i<dealCount;i++)
{
var myElem = document.createElement("TD");
myElem.id = dealMenu[i].replace(' ','_');

if(i==0)
myElem.className = "submenuhi";
else
myElem.className = "submenu";

myElem.width = 5*(dealMenu[i].length);

if(dealJsp[i] != "")
myElem.innerHTML = "<a href="+dealJsp[i]+" target='mFrame'>"+dealMenu[i].replace(' ', '&nbsp;')+"</a>";
else
{
myElem.onClick = 'productDrop();'; myElem.innerHTML = dealMenu[i];
}
alert(myElem.onClick);

myNewRow.appendChild(myElem);
}
myTable.children[0].appendChild(myNewRow);
}
function productDrop()
{
alert("Hi");
}


Thanks in advance,
Srinivasan r.
May 18 '07 #5
rsrinivasan
221 100+
Hi,
I cant send full code. Because it is our client code. So i sent only where i have the problem.

Thanks,
Srinivasan r.
May 18 '07 #6
dmjpro
2,476 2GB
now the picture is more clearer than before ......

actually myElem.onClick = 'productDrop();' this line does not work.....right!!!!!!!!!!!!!!!!!!

actually myElem.onlCick takes no string assignment ... actually it takes the function_referenece.

i think u got my point.
try urself ... if anything wrong then we r here.
best of luck.

kind regards.
dmjpro.
May 18 '07 #7
acoder
16,027 Expert Mod 8TB
onClick should be onclick (lowercase "c").
May 18 '07 #8
rsrinivasan
221 100+
now the picture is more clearer than before ......

actually myElem.onClick = 'productDrop();' this line does not work.....right!!!!!!!!!!!!!!!!!!

actually myElem.onlCick takes no string assignment ... actually it takes the function_referenece.

i think u got my point.
try urself ... if anything wrong then we r here.
best of luck.

kind regards.
dmjpro.

Hi dmjpro,

I understand. But i do not know how to do it. I need exact code how to set the event. I try it lots of ways. but still it does not work. So plz if possible sent it immediately.
Thanks,
May 18 '07 #9
dmjpro
2,476 2GB
okkk.....

do the line myElem.onClick = 'productDrop();' as ....
myElem.onClick = productDrop();

i think this ll work..... if not then come again i m here.

kind regards.
dmjpro.
May 18 '07 #10
rsrinivasan
221 100+
okkk.....

do the line myElem.onClick = 'productDrop();' as ....
myElem.onClick = productDrop();

i think this ll work..... if not then come again i m here.

kind regards.
dmjpro.
Hi,
Ya. It is called automatically when that line executed. But it will not fire when i click that TD.
May 18 '07 #11
rsrinivasan
221 100+
okkk.....

do the line myElem.onClick = 'productDrop();' as ....
myElem.onClick = productDrop();

i think this ll work..... if not then come again i m here.

kind regards.
dmjpro.
Hi dmjpro,

Your code is working. But the event did not fire when i click the TD. Im in urgent situation. When i click, it did not respond anything.

Thanks,
Srinivasn r.
May 18 '07 #12
dmjpro
2,476 2GB
Hi dmjpro,

Your code is working. But the event did not fire when i click the TD. Im in urgent situation. When i click, it did not respond anything.

Thanks,
Srinivasn r.

then do one thing .... myElem.onClick = function(){alert('Helooo.....Yahoooooo')};
do one more thing ....myElem.onClick .......check the case sensivity for onClick

best of luck ...
plz give me feed back.
i m online.

kind regards.
dmjpro.
May 18 '07 #13
rsrinivasan
221 100+
then do one thing .... myElem.onClick = function(){alert('Helooo.....Yahoooooo')};
do one more thing ....myElem.onClick .......check the case sensivity for onClick

best of luck ...
plz give me feed back.
i m online.

kind regards.
dmjpro.
Hi,
I try it. I replaced my code with ur code. But it did not work. what to do?

Expand|Select|Wrap|Line Numbers
  1.     myElem.onClick = function ff(){alert('Helooo.....Yahoooooo');}
Thanks,
Srinivas r.
May 18 '07 #14
dmjpro
2,476 2GB
Hi,
I try it. I replaced my code with ur code. But it did not work. what to do?

Expand|Select|Wrap|Line Numbers
  1.     myElem.onClick = function ff(){alert('Helooo.....Yahoooooo');}
Thanks,
Srinivas r.

hello ... i told u to write ..... anonymous function .....

u should write function() only instead of .... funciton ff() ... understood..
best of luck.

kind regards.
dmjpro.
May 18 '07 #15
rsrinivasan
221 100+
hello ... i told u to write ..... anonymous function .....

u should write function() only instead of .... funciton ff() ... understood..
best of luck.

kind regards.
dmjpro.
Hi,
I try it in both way. But it did not fire, when i click.

Thanks,
Srinivas r.
May 18 '07 #16
dmjpro
2,476 2GB
now try a sample code.

<body onload = test1()>
<input type = button id = test_name>
</body>

now write in script part....

function test1()
{
document.getElementById('test_name').onClick = function(){alert('DMJPRO: yahoooooo........');}
}

plz give me the feed back immediately .. i m online.
i ll not sign out untill u give me the feed back.

kind regards.
dmjpro.
May 18 '07 #17
rsrinivasan
221 100+
now try a sample code.

<body onload = test1()>
<input type = button id = test_name>
</body>

now write in script part....

function test1()
{
document.getElementById('test_name').onClick = function(){alert('DMJPRO: yahoooooo........');}
}

plz give me the feed back immediately .. i m online.
i ll not sign out untill u give me the feed back.

kind regards.
dmjpro.
Hi,
Sorry. Yesterday I went out. Thats why I cant reply immediately. I try your code today. But it did not work. Im creating TD id also in javascript(dynamically) as below. So when i refer
document.getElementById('myElem.id')
it gives error

Expand|Select|Wrap|Line Numbers
  1. myElem.id   = dealMenu[i]
Thanks,
Srinivas r
May 19 '07 #18
acoder
16,027 Expert Mod 8TB
Im creating TD id also in javascript(dynamically) as below. So when i refer document.getElementById('myElem.id') it gives error
Expand|Select|Wrap|Line Numbers
  1. myElem.id   = dealMenu[i]
Get rid of the quotes and use
Expand|Select|Wrap|Line Numbers
  1. document.getElementById(myElem.id)
because that contains the actual id.

Did you change the onClick to onclick?
May 21 '07 #19
sumittyagi
202 Expert 100+
Hi,
I try it. I replaced my code with ur code. But it did not work. what to do?

Expand|Select|Wrap|Line Numbers
  1.     myElem.onClick = function ff(){alert('Helooo.....Yahoooooo');}
Thanks,
Srinivas r.
The best way is to use DOM standard functions so that ur code become browser independent.
Expand|Select|Wrap|Line Numbers
  1. if(item.attachEvent)
  2. {
  3.     item.attachEvent('onmousedown', functionName);
  4. }
  5. else
  6. {
  7.     item.addEventListener('mousedown', functionName, false);
  8. }
  9.  
Note:- difference between function call and function reference is that, function call is function name with paranthesis, while function reference is function name without parenthesis.

Whenever you define any anonymous function then it returns its reference, so you can also get reference of anyonymous function.

~~Cheers~~ ;-)
May 21 '07 #20
rsrinivasan
221 100+
The best way is to use DOM standard functions so that ur code become browser independent.
Expand|Select|Wrap|Line Numbers
  1. if(item.attachEvent)
  2. {
  3.     item.attachEvent('onmousedown', functionName);
  4. }
  5. else
  6. {
  7.     item.addEventListener('mousedown', functionName, false);
  8. }
  9.  
Note:- difference between function call and function reference is that, function call is function name with paranthesis, while function reference is function name without parenthesis.

Whenever you define any anonymous function then it returns its reference, so you can also get reference of anyonymous function.

~~Cheers~~ ;-)
Hi,
I solved my problem in some other way. But your code looking nice. I'll try your code also.

Thanks for ur reply,
Srinivas r.
May 21 '07 #21
rsrinivasan
221 100+
The best way is to use DOM standard functions so that ur code become browser independent.
Expand|Select|Wrap|Line Numbers
  1. if(item.attachEvent)
  2. {
  3.     item.attachEvent('onmousedown', functionName);
  4. }
  5. else
  6. {
  7.     item.addEventListener('mousedown', functionName, false);
  8. }
  9.  
Note:- difference between function call and function reference is that, function call is function name with paranthesis, while function reference is function name without parenthesis.

Whenever you define any anonymous function then it returns its reference, so you can also get reference of anyonymous function.

~~Cheers~~ ;-)
Hi,
I solved it. But i have another problem.

Im using two frame in my jsp page. In this first frame has header and second frame has body. In the header frame i have one menu. When I scroll down the body frame, the menu item is hidden by the body frame. How to resolve it...

Thanks,
Srinivas r.
May 21 '07 #22

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

Similar topics

8
by: Sticks | last post by:
ok... im not quite sure how to describe my problem. i have a php script that runs through my entire php site and writes the resulting output to html files. this is necessary as the nature of the...
6
by: Paul Winkler | last post by:
This is driving me up the wall... any help would be MUCH appreciated. I have a module that I've whittled down into a 65-line script in an attempt to isolate the cause of the problem. (Real...
1
by: Kevin Potter | last post by:
We have an application that has been running on IIS4 and IIS5 for quite some time, without problem We're now migrating to IIS6 (windows/2003), and have run into a what might? be a Javascipt...
13
by: nobody | last post by:
Hello all, I've searched just about everything and although I can see that other people are having problems, but theirs don't seem to relate, so in a last ditch attempt, my posting! Script...
7
by: Russ | last post by:
Hi All, I have a problem getting the following simple example of "document.write" creating a script on the fly to work in all html browsers. It works in I.E., Firefox, and Netscape 7 above. It...
2
by: Ivan Demkovitch | last post by:
Hi! I'm trying to add script to the page and place following code in my ascx (control): Page.RegisterClientScriptBlock("adder", "<script>function...
4
by: petermichaux | last post by:
Hi, I'm hoping for a reason I'm wrong or an alternate solution... I'd like to be able to dynamically include some javascript files. This is like scriptaculous.js library but their solution is...
9
by: Jerim79 | last post by:
Here it is: <?php if($_SERVER=='POST'){ $Number=$_POST; $Email=$_POST; $Number2=0; $error=0;
3
by: GazK | last post by:
I have been using an xml parsing script to parse a number of rss feeds and return relevant results to a database. The script has worked well for a couple of years, despite having very crude...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...

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.