If I have the following variable which contains the drop down menu for list of card numebrs:
var abc='<option value="1234567890123456">1234567890123456</option><option value="0987654321987654">0987654321987654</option><option value="0147852369014785">0147852369014785</option>'
How can I pass this variable to a function and mask only the dispalyed card number? i.e. to have the following result:
Note: the number of options in the drop down menu may varry, in this example its only 3 options, it might be more or less, this is why I called it "Smart Substring".
I have URLs as follows. [URL] I need a function which can retrieve substring from the above URLs. The substring should be upto the 2nd occurence of '/' as follows. [URL]
I have a validation script for upc codes which is currently working for values that are entered into one text box. I've been asked to break up the text box into 3 separate fields to accept the 1st digit, middle 10 digits, then last check digit. What I'm doing is substringing the initial values then concatenating them. What I'm not sure of is, how to handle the validation. I was previously firing an onBlur after the text box but now that I have three, and I need the values to concatenate into one for the validation. Should I just fire a function after the 3rd field that concatenates the 3 values, then pass that value to the validation function? Or is there a better way?
I was also wondering if there was something I could find like an input mask, but something that could just "overlay" on top of a regular text box with one value which could give the appearance of having separations for certain digits, in this case the first and last.
I am trying to take a form input field and take what was entered and grab the first 8 character of what was entered and then submit that to a form instead of what was entered.
I am looking for a function that will replace last occurence of a substring from a string: tmpStr: xxx, yyy, zzz, sss, The desired outcome: xxx, yyy, zzz and sss (ie: remove last letter and then replace last occurrence of ",") The string can differ,
* xxx, * xxx, yyy, * xxx, yyy, zzz,
Do anyone of you have a neat fuction for that? I will be so happy for all input!
I'm trying to read the substring of a url so when the page loads up, it would know if it needs toimmediatelyjump to another tab.So a user clicks a link like this:[URL] On that page, there are already functions listening for click events on objects with a class names like "gotoTab2".So all I really need is for jquery to check if there's a '#something' in the url when the page loads up, and if so execute a 'click' on that substring as if it was a class.
I have been able to use javascript to place the last modified date in the bottom left corner of my document however I do not need the time with it. How do I use the substring() method on the lastModified property? Here is what it looks like.
<script type="text/javascript"> <!--Hide from old browsers var today = new Date() var dayofweek = today.toLocaleString() dayLocate = dayofweek.indexOf(",") weekDay = dayofweek.substring(0, dayLocate) newDay = dayofweek.substring() [Code]..
I'm trying to get the value of an input box after a delete key has been pressed at a certain position. For example: If I have: afghanistan and my caret is at position 4 and I push delete I will be left with: afghnistan I'm able to determine the caret position and detect the delete key and then I am trying to use slice to return the new value of the string like: Code: value.slice(caretPosition,caretPosition+1) This returns the value of what was sliced out of the string - how can I modify the parameters of slice to return everything BUT the removed part?
I need help with substring or trim function in javascript. Find below my code. Selection holds the value Select State, and length of the string is 14. I need to equate the Selection value to string "Select State" and execute alert message.
function selected_item() { if (Selection=="Select State") alert("Select the State");[code]....
I tried this:
var state=Selection.substring(0,11); and then string would be equated to state variable. But it is not working.
I'm working on some code and am running into brick walls. I'm trying to write out Javascript with Javascript and I've read the clj Meta FAQ and didn't see the answer, read many similar posts (with no luck though), and searched through the IRT.ORG Faqs (www.irt.org/script/script.htm).
The Javascript is designed to open an popup window and then inside that window call another script which will resize that window. There may be another way around this but the reason I tried this approach initially was that I wanted to call the onload handler in the popup window to resize the image only after the image had completely loaded. I've had some code in the primary Javascript file (showimage.js) before that works if the image has been cached but on the first load, it doesn't resize properly which tells me it is probably because it is trying to resize the window based on the image size but it isn't completely known at that point. So I removed that code and tried placing the resizing code in the second Javascript file (resizewindow.js). BTW I've tried other code to open a popup image and automatically size it ie Q1443 at irt.org but that doesn't do exactly what we need.
Even if there is another way to do this with one file, I still want to figure out why this isn't working in case I run into it in the future.
I thought what I would need to do to use document.writeln to write Javascript would be to escape any special characters and to break apart the script tag ie
document.writeln('</SCRIPT>');
would become
document.writeln('</SCR' + 'IPT>');
I have a HTML page and 2 Javascript files. All files are in the same directory and have permissions set correctly.
Here are the 3 files (keep in mind wordwrap has jacked up the formatting):
index.html ---------- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Test</title> <SCRIPT type="text/javascript" LANGUAGE="JavaScript1.1" SRC="showimage.js"> </SCRIPT> </head>
<body> Click the house<BR> <A ONCLICK="newWindow1('house1.jpg','Nice House')"><IMG SRC="house1thumb.jpg"></A> </body> </html>
showimage.js ------------ function newWindow1(pic,sitename) {
resizewindow.js --------------- function resizewindow() { // Do resizing here. // Right now this isn't being executed alert("resizing window"); }
Can anyone provide some pointers as to why this javascript is failing? I'm using IE6 on Win2k and when I click on the image to open the popup window, it does open the window but it is white with no content and the system immediately goes from about 4% CPU usage to 100% and consistently stays there until I kill that window with the task manager.
Attached is a simple HTML file that adds and delete rows. In the add row function I set an attribute "onClick" this triggers the testMessage() function. When I try this in Firefox it works just fine however on IE it just refuses to work.
What is interseting is the ROW that already exists has a similar 'onClick' event which works when the page is loaded, but subsequent "row" additions to the table to not work in IE. Code:
I'm getting errors in Firefox everytime I try to run this frame resize code, but it works fine in IE. I can't seem to figure out what the problem is with it.
The error is: Error: theFrame has no properties Line: 8
The line that the javascript console is showing an error for is in italics.
I'm already past the basics of Javascript, and i need something that takes me to the other level and teaches me the new technologies and cool stuff (drag&drop, AJAX, OOP in javascript, maybe XUL...etc). So far i found these two books:
1. Sitepoint's "The JavaScript Anthology: 101 Essential Tips, Tricks & Hacks". 2. Worx's "Professional JavaScript for Web Developers (Wrox Professional Guides)"
Both seems to cover very insteresting topics, but i can only buy one of them. So which one do you suggest?
and by the way, i've read the sample chapter 5 of Sitepoint's book, and it seems like the author(s) just put the solutions/codes there and let you figure them out on your own. Is this how the rest of the chapters are?
This is a question about defensive web browsing. Ocassionally I run into a page whose JavaScript does something that I find obnoxious. I would like to turn off JavaScript only for that page (instead of disabling it globally). It would be cool if there were some way to do this through a "bookmarkable" JavaScript snippet using the javascript: pseudoprotocol. Does anyone know any trick to do any of this?
I am looking for a method to extract the links embedded within the Javascript in a web page: an ActiveX component, or example code in C++/Pascal/etc. I am looking for a general solution, not one tailored to a particular page/script.
Hopefully, the problem can be solved without recreating a complete Javascript interpreter. Any ideas?
I have some javascript that I have written into the <body> section and it works great. But I would like to make it into a javascript function and define the function in the <head> section. Then in the <body> section write a small bit of javascript that would call the function() object. Code:
I would like to know how to write javascript such that, a part of it isnt considered as script, & rather as HTML. Code:
Ok, the layer div can be written using document.write. But, Google ad itself is a javascript isnt it. How can it be written into this? How does this work?
Ok so, this is my purpose: - to be able to load asynchronously (via AJAX) some javascript ads (like google's or adbrite) so as to make them be loaded in the background, then update the page after the ads have loaded via innerHTML
Why? -Because 90% of the time in my newer sites, javascript ads are the major offender in terms of speed of page rendering
My problem: Via ajax, I can call a php file that retrieves some javascript and outputs it, XMLhttprequest returns those javascript lines, but they don't render in the page, since they miss the whole page loading, and are apparently not parsed For example, let's say I call a php file via ajax, and it returns the output into a variable named "text" containing "document.write('hello')" if I use xxx.innerHTML=text, nothing happens
My 1st solution: Passing those javascript lines to eval() [like eval(text) ], but this produces a second problem, that I couldn't solve (probably because of my lack of knowledge in javascipt): if I eval the code, it deletes my current page and renders a new one for example, if I parse a document.write, my page disappears, and a new one is rendered with the document.write text
What I want is basically to make that "document.write" appear inside a div in my page, adding to the content (and not overwriting the whole page), much like what happens when using innerHTML
Is this even possible? How would you go about it? I tried xxx.innerHTML=eval(outputfromphpfile) but it overwrites my whole page...