how to set the value for the anchor tag in javascript

Posted by Rajass22 under ASP.NET on 9/11/2013 | Points: 10 | Views : 3228 | Status : [Member] | Replies : 3
hi

i am doing the website with functionality of zooming


<span>
<a id="placeholder" runat="server" rel="zoom-width:600px; zoom-height:600px" class="MagicZoom">

<asp:Image ID="images" BorderWidth="1px" BorderColor="LightGray" runat="server" onerror="this.onerror=null;this.src='../Image/noimage2.png'" Width="250px" /></a>

</span>



on page loads

i am assigning the value like

this.images.ImageUrl = "../Image/temp/" + stylecode.Trim() + ".jpeg";

placeholder.HRef = "../Image/temp/" + style_code.Trim() +".jpeg";

on mouse over i am using the function like
string mainimgurl = "../Image/temp/" + style_code.Trim() + hdncolorcode.Value.Trim() + ".jpeg";
lblcolorname.Attributes.Add("onmouseover", "javascript:setmainimgg('" + mainimgurl + "');");

and javascript function is

function setmainimgg(iiisd) {
document.getElementById(<%= images.ClientID %>).src = iiisd;
document.getElementById(<%= placeholder.ClientID %>).href = iiisd;
}

here images control value is changed it's shows the correct image. But the problem is href(anchor tag) value is not changing. if the value path changes means the zoom will work i can't assign the value for anchor tag.




Responses

Posted by: Allemahesh on: 9/11/2013 [Member] [MVP] Silver | Points: 25

Up
0
Down
Dear Rajass,

You try the below code:-

function setmainimgg(iiisd) { 

document.getElementById(<%= images.ClientID %>).src = iiisd;
document.getElementById(<%= placeholder.ClientID %>).setAttribute('href', iiisd) ;
}


OR

function setmainimgg(iiisd) { 

document.getElementById(<%= images.ClientID %>).src = iiisd;
document.getElementById(<%= placeholder.ClientID %>).attr('href', iiisd);
}


Happy Coding.

If it helps you or directs U towards the solution, MARK IT AS ANSWER

Rajass22, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bandi on: 9/11/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
Refer this link
http://stackoverflow.com/questions/3998496/change-the-href-of-an-anchor-tag-with-javascript

Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Rajass22, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rajass22 on: 9/11/2013 [Member] Starter | Points: 25

Up
0
Down
Thank u for your reply

I have tried both the method it doesn't work..

once the placeholder is assigned the path on page loads in cs page.

I cannot change the another path using javascript.


Rajass22, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response