473,624 Members | 2,394 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to pass a SPAN id to the .js function.....

17 New Member
hello ,
i have to pass a 'span' id to the javascript function'. how can i pass that.

when i tried like below it is working!!! may the function is in the same page....
eg:
----
Expand|Select|Wrap|Line Numbers
  1. <html>
  2.             function dscptAction(){
  3.                 var obj = document.getElementsByTagName("span");
  4.                 for(i=0;i<obj.length;i++){
  5.                 ............
  6.                 .........
  7.                 ..... 
  8.             }
  9.  
  10. <body>
  11. <span>
  12. <table >
  13. <tr>
  14.  <td>
  15.     <select value="" onclick="dscptAction()">
  16.     </option value="1">1</option>
  17.     </option value="2">2</option>
  18.   </td>
  19. </tr>
  20. </table>
  21. </span>
  22. <span id ="dscpt">
  23.   <table>
  24.   </table>
  25. </span>
  26. <span id ="addr">
  27.   <table>
  28.   </table>
  29. </span>
  30. </body>
  31. </html>
  32.  
i am want to place my javascript{"dsc ptAction()"} function to the .js file, In this case how can i pass the 'span'Id to javascript.

for example:


Expand|Select|Wrap|Line Numbers
  1. <html>
  2.        <script language="javascript" src="../../js/module.js"></script>  // this contains  my dscptAction() function....
  3. <head>
  4.  
  5.  
  6. </head>
  7. <body>
  8. <span id="name">
  9. <table >
  10. <tr>
  11.  <td>
  12.     <select value="" onclick="dscptAction()">
  13.     </option value="1">1</option>
  14.     </option value="2">2</option>
  15.   </td>
  16. </tr>
  17. </table>
  18. </span>
  19. <span id ="dscpt">
  20.   <table>
  21.   </table>
  22. </span>
  23. <span id ="addr">
  24.   <table>
  25.   </table>
  26. </span>
  27.  
  28. </body>
  29. </html>
  30.  



thx,
Ajay
Aug 27 '07 #1
1 3628
dmjpro
2,476 Top Contributor
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <body>
  3. <span>
  4. <table >
  5. <tr>
  6.  <td>
  7.     <select value="" onclick="dscptAction()">
  8.     </option value="1">1</option>
  9.     </option value="2">2</option>
  10.   </td>
  11. </tr>
  12. </table>
  13. </span>
  14. <span id ="dscpt">
  15.   <table>
  16.   </table>
  17. </span>
  18. <span id ="addr">
  19.   <table>
  20.   </table>
  21. </span>
  22. </body>
  23. </html>
  24.  
i am want to place my javascript{"dsc ptAction()"} function to the .js file, In this case how can i pass the 'span'Id to javascript.

for example:


Expand|Select|Wrap|Line Numbers
  1. <html>
  2.        <script language="javascript" src="../../js/module.js"></script>  // this contains  my dscptAction() function....
  3. <head>
  4.  
  5.  
  6. </head>
  7. <body>
  8. <span id="name">
  9. <table >
  10. <tr>
  11.  <td>
  12.     <select value="" onclick="dscptAction()">
  13.     </option value="1">1</option>
  14.     </option value="2">2</option>
  15.   </td>
  16. </tr>
  17. </table>
  18. </span>
  19. <span id ="dscpt">
  20.   <table>
  21.   </table>
  22. </span>
  23. <span id ="addr">
  24.   <table>
  25.   </table>
  26. </span>
  27.  
  28. </body>
  29. </html>
  30.  
Edit the function as .......
Expand|Select|Wrap|Line Numbers
  1. dscptAction(this.parentNode.parentNode.parentNode.parentNode)
  2. //Here the span object will be passed
  3.  
Kind regards,
Dmjpro.
Aug 27 '07 #2

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

Similar topics

15
3094
by: Sue Barth | last post by:
Hi all, I hope I'm in the right ng for this... I made an .asp page that allows users to toggle thru a directory of photos. The page accomplishes the following: selects a directory of photos based on a drop down uses the fso to obtain the # of photos in the directory cycles thru the photos w forward and backward buttons that send the pic # with a +1 or -1 value retrieve's & displays the rs's photo description field from a db based
2
6015
by: Mike | last post by:
I´ve got a number of SPAN elements named "mySpan1", "mySpan2", "mySpan3" etc, and want to set their "style.display" to "inline". This works (only needs to work on IE5.5+): for (var x = 1; x < 20; x++) { document.all('mySpan'+x).style.display = "inline"; } But I don´t know how many SPAN elements there are, so I need to set x to a
9
6801
by: Wang, Jay | last post by:
Hello, all, I would like to enable some text between <SPAN url="http://www.testserver.com/">WORD TO BE DRAGGED </SPAN>. I put some javascript and it will extract http://www.testserver.com/ from the the span element when I select the whole text in the SPAN and drag it. However, I want to drag it without have to select the words between the span element. The default mouse action will only select the words when i move the mouse. Can...
7
3440
by: olga | last post by:
Hi, On my site, i want to pass a javascript variable to php. I know that this needs to done in a link or in a post. I want to know if there is a way i can do it with an html link. I should mention that these will be dynamically created links in php. This is an optional value so if javascript is disabled, my site will still function. the browser_width() function works correctly but when i
2
3345
by: Alex | last post by:
On my page I have a lot string like this: <span onmouseover="callMe(this)" onmouseout="callMe(null)" >abc1</span> <span onmouseover="callMe(this)" onmouseout="callMe(null)" >abc2</span> <span onmouseover="callMe(this)" onmouseout="callMe(null)" >abc3</span> <span onmouseover="callMe(this)" onmouseout="callMe(null)" >abc4</span> How can I optimize it? Is it possible to move this definition what to do to style/css or some other common...
1
1641
by: Chanaka | last post by:
We are trying to pass the selected date from a .net calendar in a querystring. We manage to display the selected date from the calendar in a Lable like this : protected void Calendar1_SelectionChanged(object sender, EventArgs e) { lblDate.Text = Calendar1.SelectedDate.ToShortDateString(); } <asp:Label ID="lblDate" runat="server"></asp:Label>
19
9073
by: nazgulero | last post by:
Hello all, I wonder if anybody can give me a hint about what I have to do to get this working: I am creating a drop down box using the script below. The result is two text fields; now I want to pass those values, which come from the drop down box, to the next page. The next page should then simply look like this:
3
1552
by: Adam | last post by:
I am creating a program to create sudoku games. I have an object that is 1 row of a sudoku game. I store the initial state of the row before I start figuring out the values to place in each cell, in case the program runs into a problem and has to revert the row back to its original state. So first I store the initial State of the row, then I start to modify the row. My problem is that once I start to change the original row, it also...
4
3159
by: bgold12 | last post by:
Hey, I have kind of a weird problem. I have a span that I'm intentionally overflowing a table cell (<td>), so that it stretches over the table cells to the right of the parent table cell. I want the mouseover event to occur for the table cells that lie underneath the overflowed span, but every time i put the mouse on the span the mouseover event for the parent table cell is called. Any suggestions? Thanks.
0
8240
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8175
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8336
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8482
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7168
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4082
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2610
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1791
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1487
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.