File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Passing values dynamically in Anchor

 
Praveen Kumar Anekalmath
Greenhorn
Posts: 18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

}
 
Omer Haderi
Ranch Hand
Posts: 42
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dude this is Java forum for the Sun Certification Not a javascript forum, there are plenty of javascript forums !
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From the SCJP forum with love...
 
Roger F. Gay
Ranch Hand
Posts: 408
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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 ]
 
Praveen Kumar Anekalmath
Greenhorn
Posts: 18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic