Reputation: 311
I have a input field that has the id #formValueId
<input id="formValueId" type="text" class="form-control" placeholder="email address" name="unsubemail">
I'm using this function here as well,
function addURL(element) {
$(element).attr('href', function(){
return this.href + 'unsubscribe-complete?q=direct_unsubscribe&fn=Public_DirectUnsubscribeForm&id=IDSTRING&' + 'unsubscribeEmail';
});
}
I also created a variable like this,
var unsubscribeEmail = $("#formValueId").val();
at the end of my addURL function for return this.href line I'm adding the variable to the end of it and it works great but the url isn't passing the val(); it's just putting the var name at the end. what am I doing wrong here?
+ 'unsubscribeEmail';
Upvotes: 0
Views: 263
Reputation: 24001
by using 'unsubscribeEmail'
you make it just string so use unsubscribeEmail
instead of 'unsubscribeEmail'
function addURL(element) {
$(element).attr('href', function(){
return this.href + 'unsubscribe-complete?q=direct_unsubscribe&fn=Public_DirectUnsubscribeForm&id=IDSTRING&' + unsubscribeEmail;
});
}
Upvotes: 1