I have a function that sets a value of this.name. If I call a function of that function (is there a better term for that?), I can get the value of that name with this.name. However, if I save that function's function as a variable, and THEN call it, this.name is undefined.
I don't think my vocabulary is clear enough, so here's my example: function Ninja(name){ this._name = name; this.getName = function(){ return "ninja "+this._name }}
sam = new Ninja("sam"); assert( sam.getName() == "ninja sam", "Ninja's name is ninja sam" ); sam2 = new Ninja("sam2"); sam2getName = sam2.getName; assert( sam2getName() == "ninja sam2", "Ninja 2's name is ninja sam2" ); //fails log("Ninja 2's name is actually "+sam2getName()) // actually "ninja undefined"
(Note: Use of "ninja" and assertions are because I was playing with the code in John Resig's java runner thingie: [URL]). The reason I want to be able to refer to a function by a variable is because I want to pass the function to something else that requires a function to be passed in, such as an ajax callback or something. Anyway... why is this.name undefined in the second example?
I am trying to re-write a script that I found on w3schools. The script should check whether ALT key was pressed or not. My objective is not to use any inline scripts and to refer to the event within a function. My script is not working.
<code> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml">[code].......
I have a regular html page called a.html this page opens a modal dialog window called modal1.html modal1.html contains a 'Next' button. when the button is pressed the modal1.html is replaced with modal2.html
modal2.html contains another button. when its button is pressed, the modal dialog window should close and the location of the original page a.html should change. I am trying to do something like:
I attach a mouseover event to a ul. Within the function I can use $(this) or this to refer to the ul.How can I refer to the li element over which the mouse is? And therefore make use of event delegation in jQuery.
function JGallery(){ this.name="defaultGallery"; this.images=[{//some JSON here}] this.render=function(){
[Code].....
I've tried to debug it in firebug, but I guess there is a problem with the scope of the 'this'. The 'this' in
//i want append div with id of the name property of jgallery class $("<div></div>").appendTo("#container").attr("id",this.name); seems to refer to the iterator in the $.each().
I've tried to do this.this.name but it still doesn't work. Is there any way to allow me access the property of the Jgallery class?
I am creating an application that uses as much Object Oriented code as I could (mostly to learn it).
I have an object called 'photo' that contains two Image() objects 'fullImage' and 'thumbnail'. All is fine and dandy, I can read the thumbnail and the full image, and their associated properties just fine.
But what I can't seem to do is make the thumbnail's onclick event refer to one of the object's methods.
Here is a greatly simplified version of the object's code.
Code:
So, the thumbnails div gets populated with the thumbnails fine. But for the life of me, I cannot figure out how to make the onclick call the photo object's "editPhoto" method.
Will the way that I am creating the objects using the same name for each one, result in only the last one created being accessible. If so, do I need to create an array of objects so I can uniquely identify each one?
I'm passing the id of a div as a parameter. I'm not sure how to refer to it with Jquery. The following does not work: Code: function updatemail(param1, param2) { $("#param2").animate({ opacity: "show" }, 300); } I also tried $(param2) but it did not work.
I am calling the JS function GenRWType which is carrying the name of the dropdown.....the issue is how do I get the value of the selected option from dropdown ? This is the code I have and it does not recognize "rname"
I'm using getJSON to retrieve information from a header record and the corresponding detail records and display the detail records in a table. The PHP script that is called returns a JSON string (via json_encode) that looks like this:
Here is the html table: <table><thead><tr> <th colspan="2" >Item Description</th> <th>Quantity</th> <th>U/M</th> <th>Item Price</th> <th>Item Amount</th> </tr></thead><tbody> <tr class="p_row_1"> .....
And here is the $.getJSON: $.getJSON("GET_INV_INFO.php",{srn:'<?php echo $srn; ?>'},function(s){ // Get Header Info $('#ip_invNo').html(s.jobNo); $('#ip_invDate').html(s.invDate); $('#ip_custNo').html(s.custNo); $('#ip_purchOrd').html(s.purchOrd); $('#ip_custName').html(s.custName); .....
My problem comes in the getJSON section where I'm trying to populate the table with a record. I don't know how to refer to the different fields in array 's'. I've tried the following and many variations, but to no avail: $('.p_row_'+i+':nth-child(1)').html(s.row.i.itemNo); $('.p_row_'+i+':nth-child(1)').html(s.row[i].itemNo); How do I refer to a nested field in a multidimensional array like this?
I want to put a value in a cookie. The following code does not work. It does not store the box1.value in the cookie. How can I fix it? <input type="text" name="box1" onblur=document.cookie="user=" + box1.value>
I am trying to create a chrome extension that can pass text from a text box to a webpage text box. Basically my company has an intranet site where you can search for an employee. The url does not display the search terms so i cant just append to it. Since I cant really work on this outside of work (its an intranet site) i have tried replicating it from home using the let me google that for you (www.lmgtfy.com) site.
Now that is fine when the text is only one line long. Suppose it's longer? What I want to do is have Javascript give the variable contentString its text from a hosted text file in a similar manner to the way Javascript can insert more Javascript using a hosted .js file.
I illustrate what I need to do using some "dummy" javascript:
I have a form with 9 text fields and a text area. What I want to do is replace the text in the text area depending on how many fields contain text. For example my text boxes are named 1 to 9, if the user enters text in the first five boxes I want the text area to auto fill with 'you have selected boxes 1 to 5' if the user selects all nine it will say 'you have selected 1 to 9', therefore, the user must complete the text boxes in order. I have it working with an onchange event but i have a button on the form to also auto fill the text boxes and it does not work if this is clicked
As of right now I have a code that will work in IE but wont work in FireFox...go figure. Basically what I want to have happen is when you type in an area code it will provide an output in a predetermined area of the page.
For Example: Input- 512 Output - Austin, TX
The code that I have doesn't work with firefox and I was just wondering if there was a code that would allow that to happen.
Would u pls let me know whether the following is possible or not: User can be able to insert text on a text-box or text-area(form) as usually we use text-area to do so. But I want to put some readonly text using an open and close tag
for example: <ro>This is readonly text</ro>insert your text here Can I be able to make the text inside <ro>..</ro> tag readonly, it means user can't be able to modify or delete this readonly text. readonly text length not fixed. only way to recognize the readonly text is the <ro> tag.
I have a text field (field1) already displayed on the HTML page. However, there's a link where you can add additional text fields to the page as well. When the link is clicked, the second text field is added successfully (field2), and when the link is clicked again, the third text field (field3) is added successfully. However, the third field does not add itself to the page, and the text for anything greater than a third field also isn't displayed after. This obviously means that my "fields" variable is not working right
There is a Text Area that user can enter text. assume that user enter something and put a dot Following values should be populate in a drop down at the place where dot locate .
like when we get the string object using Net Beans IDE and when we put "Object." , drop down will be displayed with available methods for that particular object. idea is to build a editor using java script.
I am new to javascript, and am having an issue, which I'm sure is elementary.. I found a script for expandable content, it suffices fine. As it stands, the script toggles images onclick. For example, whence the menu is collapsed, it displays "plus.gif" next to it, and when the menu is expanded, it displays "minus.gif" next to it.
Basically, what I would like to know is, thus: how would I change it to display text icons next to it? For example, in place of "plus.gif" I should like it to display "+" as actual text. I've dredged a number of places, however, I've found nothing. Furthermore, I cannot figure out how to do it.
I m having a text data of around 6 page length in a text editor...I want to print dat data using window.print. For that i displayed dat data in a html page and used window.print(). Bt my client wants dat some line spaces shud be inserted first in the starting of the page and on the second page also...After that the printing shud be normal... How can i set the page in such a format...?
I want to get the cursor start and end position of a selected range in a text-field or text-area. i tried lot of functions in various forums. but when the last character of the selection is a new line character JavaScript ignore it in IE6. any one having idea ?
Is it possible to have a text box input searching for the entered text on another webpage in the same way Find In Page would do? I have a webpage that I want users to input an item, and that this will open the targeted webpage and bring you to (and highlight) the matched item(s) like find in page does. Is this possible or is the easiest way to just make users open the link to the target page and just complete the find in page search there?
Have a small problem with a cms whereby when i try to insert default text into an input text field using the "value" attribute it gets deleted. I was thinking to force insert the text in there when the page load with javascript but not sure exactly how...
<p><input name="vericode" id="vericode" value="This text doesn't display!!" type="text" onclick="value=''"/></p>