0

I am using prototype in my application but I am not sure how to add this correctly. Basically I have the following function and I need to construct the href of an anchor from which I already have the reference to a series of appended values

MyJavascriptClass.prototype.init = function() {
    this.ToDate = $(this.Prefix + 'ToDate');
    this.FromDate = $(this.Prefix + 'FromDate');
}

so in the following function I need to add those as parameters in the url attribute

MyJavascriptClass.prototype.btnClicked = function(evt) {

this.lnkShowLink.setAttribute('href', 'MyWebpage.aspx?StartDate=7/18/2012&EndDate=1/19/2012');

}

How can i do something like 'MyWebPage.aspx?StartDate=this.ToDate&EndDate=this.FromDate' ? Any help would be appreciated.

4 Answers 4

1

If you are using jquery, and $(this.Prefix + 'ToDate') and $(this.Prefix + 'FromDate') represent fields that contain values, then you can do this:

MyJavascriptClass.prototype.btnClicked = function(evt) {
    this.lnkShowLink.setAttribute('href', 'MyWebpage.aspx?StartDate=' + this.ToDate.val() + '&EndDate=' + this.FromDate.val() + '');
}

It is difficult to tell from your code what they represent, and why you have them wrapped in $(..).

Sign up to request clarification or add additional context in comments.

Comments

0

If ToDate and FromDate contain the two date values, then this should work...

'MyWebPage.aspx?StartDate=' + this.ToDate + '&EndDate=' + this.FromDate

Comments

0

If you don't know every properties:

var properties = [];
for(var i in this)
    if(this.hasOwnProperty(i))
        properties.push(i+'='+this[i]);
var url = 'MyWebPage.aspx?'+properties.join('&');

Comments

0
var string = "My name is: ",
    name = "Bob",
    punctuation = ".",


greeting = string + name + punctuation;

Or

var User = { name : "Bob", age : 32, sign : "Leo" },
welcome = "Hi, I'm " + User.name + ", and I'm " + User.age + " years old, I'm a " + User.sign + ", and I enjoy long walks on the beach.";

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.