473,411 Members | 2,230 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,411 software developers and data experts.

Dynamically pass value in anchor

Hi everyone,

I'm using anchor within the for loop which means the number of anchors(links) dynamically varies.
Within the anchor i'm calling one javascript function and passing the dynamic value (select ) in that. The problem is even i click any link only last value i.e..select value at i = j is passing because the looping will happen during loading the page itself...so how can i pass exact values? Do i need to set any ID for the tag?If so how? Can Anybody please help?

for(i = 1; i < = j; i++)
{
select = document.forms['MessageNew'].userId.options[i].value;

selection[i] = '<a onclick="javascript:assignValue(select);"><font size="2">'+selection1+'</font></a><br>'

}
Apr 26 '07 #1
1 3651
Hi Everyone..

Please observe the below code

function fun(){
for(i = 1; i < = j; i++){
select = document.forms['MessageNew'].userId.options[i].value;
selection[i] = '<a href="javascript:assignValue(select);"> + select + </a>';
}
}

Assume j = 10, looping will happen for 10 times and 10 links will appear.
Let us assume value of 'select' is 'ABCD' when i = 1 and at i = 10, value of select will be 'XYZ' . Observe that in href we are calling one javascript function assignValue(select) and passing select in that. This javascript will be called when i click the link, even i click link number 1, XYZ will be passed to the assignValue() since looping is completed. But i need ABCD to be passed when i click link 1 and the respective values should be passed for link2,link3...,link10.
I hope you got my prob..Please help me how can i approach the solution.
Thanks a lot...
May 4 '07 #2

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

Similar topics

1
by: Al | last post by:
Ref:how to pass value along with click of a button hi,I have created a form that has single button. as follow <asp:button id="btnCallfunction" runat="server" text="func_call" onclick="add_int" />...
3
by: john woo | last post by:
Hi in JSP, it's easy to pass value from java-variable to javascript-variable, like js_function(a) { a=<%java-class.A%> } I'm wondering how is the other way around? I tried
3
by: pei_world | last post by:
I have a user control: - using LoadControl("MyCtrl.ascx") MyCtrl _mycontrol = (MyCtrl)LoadControl("MyCtrl.ascx") Page.Controls.Add(_mycontrol); _mycontrol.Text it will be loaded when some...
1
by: pei_world | last post by:
I have a user control: - using LoadControl("MyCtrl.ascx") MyCtrl _mycontrol = (MyCtrl)LoadControl("MyCtrl.ascx") Page.Controls.Add(_mycontrol); _mycontrol.Text it will be loaded when some...
3
by: startsmart | last post by:
Hi This is first time to write and alse it is first time to show this site my problem is i need to pass value from any input type like text for example to hidden field I tried to make a...
1
by: jadeivel756 | last post by:
I BADLY NEED YOUR HELP...... HELP... hOW TO Pass value to a struct type and permanently store the data after youve given the data.The programming language is C. My problem is that as I exit the...
4
by: jadeivel756 | last post by:
I BADLY NEED YOUR HELP...... HELP... hOW TO Pass value to a struct type and permanently store the data after youve given the data.The programming language is C. My problem is that as I exit the...
0
by: perdijc | last post by:
I create a dataset via visual studio wizard and then I drag some columns to a form in details mode. So in my form I have some coontrols binding to bindingsource. If a run the project, all controls...
2
by: mccauley | last post by:
Hello I was searching and I see that this question has been asked before but I unfortunately do not see the answer. I'm new to Javascript so if I ask something impossible please let me know. ...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
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...
0
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.