Hi All,
I'm new to this community, please help in this ...

[B]do  while not rst.eof
			i=0
		   			End if
			blnOdd = Not(blnOdd)
			colName = UCase(colName)
			do  while (i < rst.fields.count)
				if (rst.Fields.Item(i).Name = colName ) then
				ValueSelected(j)=rst(i)
				selectedName="val"& j
					Response.write("<td align='center'><B><a href= ""#"" onClick=""return returnSingleValue(this,window.opener.document." & frm & "." & field & ","&ValueSelected(j)&")""  id='"& selectedName &"'  name='"& selectedName &"' value="& ValueSelected(j) &" >"&rst(i)&"</a></B></td><td align='center'>val"&j&"<input type='Checkbox' id='chk"&j&"' name='chk"&j&"' value=""ON"">chk" & j & "</td>")
				End If
				i = i+1
			loop
			Response.Write("</tr>")
			rst.movenext
			j=j+1
			Redim Preserve ValueSelected(j)
		loop[/B]

returnSingleValue() is a Javascript function, from this function I need to access all the dynamic href values in the form.
HOw do I do this ?
I tried many options, but it didnt work out..

Thanks in advance!!!

Naziatarannum,

I'm not sure exactly what you have in mind but this should help:

function returnSingleValue(clickTarget){
	//First scoot up the dom to find the form container
	var el = clickTarget;
	while(el !== document && el.tagName.toUpperCase() !== 'FORM'){
		el = el.parentNode;
	}
	//Error message if form container not found, and exit the function.
	if(el == document){
		alert('Form element not found');
		return false;//Return false to suppress the clicked element's natural href action; or return true to allow it.
	};
	//Find all <a> elements within the form
	var anchors = el.getElementsByTagName('a');
	//Now loop through the <a> elements and do whatever is necessary with each one in turn
	var i;
	for(i=0; i<anchors.length; i++){
		alert(anchors[i].innerHTML + ((anchors[i]==clickTarget) ? "\n(I was clicked)" : ''));//Example
	}
	return false;//Return false to suppress the clicked element's natural href action; or return true to allow it.
}
<form>
<a href="" onclick="return returnSingleValue(this)">Hyperlink 1</a><br>
<a href="" onclick="return returnSingleValue(this)">Hyperlink 2</a><br>
<a href="" onclick="return returnSingleValue(this)">Hyperlink 3</a><br>
<a href="" onclick="return returnSingleValue(this)">Hyperlink 4</a><br>
<a href="" onclick="return returnSingleValue(this)">Hyperlink 5</a><br>
</form>

I have made the assumption that the <a>link</a> on which you click is within the <form>, otherwise you will need to pass the form's id to the function such that it can find the form tag with document.getElementById() (instead of the "scoot up" loop).

Airshow

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.