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

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

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{"dscptAction()"} 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 3601
dmjpro
2,476 2GB
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{"dscptAction()"} 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
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...
2
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 <...
9
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...
7
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...
2
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...
1
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...
19
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...
3
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,...
4
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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: 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...

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.