Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

this.href

Status
Not open for further replies.

aforstie

Programmer
Jun 19, 2006
19
US
I am calling an external js function that I was hoping could set this.href. When I call the function I pass this.href - append_url(this.href). Within the function I define some variables from the DOM and I am hoping to use them for this .href.

<a href="link.html" onClick="append_href(this.href)">link</a>

function append_href(href) {
var placename = document.datesform.placename.value;
var statecountry = document.datesform.state_country.value;
var state = document.datesform.country.value;
var sresults='&placename=' + placename + '&statecountry=' + statecountry + '&state=' + state;
this.href=href+sresults;
}

Can anyone tell me why the this.href is not working and I suspect is not even being recognized>
 
>>this.href=href+sresults;

when u use this inside the function it refers to the function and not any object.

try this:


<a href="link.html" onClick="append_href(this)">link</a>

function append_href(theLink) {
href=theLink.href;
var placename = document.datesform.placename.value;
var statecountry = document.datesform.state_country.value;
var state = document.datesform.country.value;
var sresults='&placename=' + placename + '&statecountry=' + statecountry + '&state=' + state;
theLink.href=href+sresults;
}


if u notice i pass the link itself as the parameter...

Known is handfull, Unknown is worldfull
 
welcome...

Known is handfull, Unknown is worldfull
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top