PDA

View Full Version : how can i pass span'id to .js page through javascript Function



msg2ajay
08-27-2007, 04:36 AM
Code: ( text )
<html>
function dscptAction(){
var obj = document.getElementsByTagName("span");
for(i=0;i<obj.length;i++){
............
.........
.....
}

<body>
<span>
<table >
<tr>
<td>
<select value="" onclick="dscptAction()">
</option value="1">1</option>
</option value="2">2</option>
</td>
</tr>
</table>
</span>
<span id ="dscpt">
<table>
</table>
</span>
<span id ="addr">
<table>
</table>
</span>
</body>
</html>


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:



Code: ( text )
<html>
<script language="javascript" src="../../js/module.js"></script> // this contains my dscptAction() function....
<head>


</head>
<body>
<span id="name">
<table >
<tr>
<td>
<select value="" onclick="dscptAction()">
</option value="1">1</option>
</option value="2">2</option>
</td>
</tr>
</table>
</span>
<span id ="dscpt">
<table>
</table>
</span>
<span id ="addr">
<table>
</table>
</span>

</body>
</html>





thx,
Ajay

glenngv
08-27-2007, 07:26 AM
Putting the Javascript code in an external js file works the same as having the code inline. Calling the function will be the same.