wood burning stoves 2.0*
The moose likes HTML, CSS and JavaScript and the fly likes Passing values dynamically in Anchor Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Passing values dynamically in Anchor" Watch "Passing values dynamically in Anchor" New topic
Author

Passing values dynamically in Anchor

Praveen Kumar Anekalmath
Greenhorn

Joined: Feb 26, 2007
Posts: 18
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?
I Have not used anchor tag since it is not allowed in in posting the message
for(i = 1; i < = j; i++)
{
select = document.forms['MessageNew'].userId.options[i].value;

selection[i] = 'a href="javascript:assignValue(select);"+selection1+ /a

}


Praveen
Omer Haderi
Ranch Hand

Joined: Sep 27, 2006
Posts: 42
Dude this is Java forum for the Sun Certification Not a javascript forum, there are plenty of javascript forums !
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
From the SCJP forum with love...


Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Roger F. Gay
Ranch Hand

Joined: Feb 16, 2007
Posts: 397

I assume that the single quote on the end is only missing in your code snippet above because you accidentally deleted it along with the last >

You are building an array containing anchors. What is selection1?
[ April 26, 2007: Message edited by: Roger F. Gay ]

Correlation does not prove causality.
Praveen Kumar Anekalmath
Greenhorn

Joined: Feb 26, 2007
Posts: 18
Thanks for your kind reply Roger.

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

It is not selection1, it is select which takes the value runtime.
I missed to add single quote at last..but it is there in the code.
I think my question is not clarified for you.
I am calling function fun(), for loop executes and number of links will appear depending on the value of j.What i am trying to do is, i need to pass 'select' value for each links when i click the link but only final select value i.e for i=j, is going.so if i click any link only last select value(i=j) will go.
i need 'select' values for all the valuse of i.
Do i need to give id to anchor ? how to approach this?

Thanks a lot...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Passing values dynamically in Anchor