Replacing A Varying Substring With Itself Plus
Jul 23, 2005
I'd like to globally replace a substring specified by a regular
expression with itself along with some additional characters.
example:
var oldString = 'asdf BRACKETTHISasdfsdf sd asdBRACKETTHISasdf asd'
var newString =
oldString.replace(/sw*BRACKETTHISw*/g, '<' + ?some expression that
accesses current match? + '>' )
And newString winds up as:
'asdf <BRACKETTHISasdfsdf> sd <asdBRACKETTHISasdf>
asd'
Is there a way to do this, or do I have to use other methods?
View 1 Replies
ADVERTISEMENT
Aug 19, 2010
I'm trying to use the same tooltip but to vary the text that apears inside the tooltip according to what you hover over. I thought I could just have a list of paragraph elements in the html with different ids which I could call when needed. My javascript is :
function toolpoint_2(f)
{
var myNumber2 = document.getElementById(f.id.replace(/thumb_/,"tool"));
tooltip.show(myNumber2, 200);
}
So when you hover over a thumbnail with an id 'thumb_2_2', it gets changed to tool2_2, which is the name of the corresponding paragraph element :
<p id="tool2_2" style="display: none;">
testing number 2 thumbnail
</p>
But I guess it's not that simple because all that happens is the text in the tooltip reads : [objectHTMLParagraphElement]
View 2 Replies
View Related
Dec 7, 2011
I have been able to piece together some code for a stopwatch. I have everything the way I want it in regards to the function and look of the stopwatch, but I want to be able to set timers so that the ss() function in the code below will go and stop automatically at intervals I can set.
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Test</title>
<script type="text/javascript">
[Code]....
View 1 Replies
View Related
Dec 27, 2009
On my index.htm, I have a horizontal cell named "memberarea" which originally shows username & password input fields. After the user logs in, this area changes itself to a "Welcome Name, Lastname" field. I want that this cell displays again the username and password input fields in case of the session of the user has expired. I have tried it with the following code (within the Iframe in index.htm):
[Code]...
View 3 Replies
View Related
Jul 20, 2005
How do i find the value next to width= (500)
in:
'"../graphics/press/012.jpg" width=500 height=339'
View 6 Replies
View Related
Oct 3, 2003
what does that do?? and is there a javascript manual out there that I can look up function in?
View 8 Replies
View Related
Mar 23, 2010
I am using Ben Alman's JQuery resize plugin in order to obtain the varying computed width of an element when the window is resized (the element in question is a page wrapper that exhibits the expand-to-fit behavior of a block box, and it's computed width is obviously influenced by the resizing of the window. Essentially, what I need to be able to do, is to reference a variable that is defined in a .resize() function ('width_page') in a seperate .each() function.
[Code]...
I now understand that variables can't cross boundaries like in the example above, which leaves me a little stuck. I also understand that this is specific to the context of the .resize() function, and that it can't be taken out of it without using an element selector. Is there some way I can call the .resize() function in my .each() function?
View 3 Replies
View Related
Feb 17, 2006
I have the following string:
http://www.myurl.com/folderbit/moer.../sdaf/01354.jpg
and I want to extract the filename from it.
Do you know how to do this, if I don't know the exact names of the folders,
etc...
View 3 Replies
View Related
Sep 9, 2007
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:
<option value="1234567890123456">1234XXXXXXXX3456</option><option value="0987654321987654">0987XXXXXXXX7654</option><option value="0147852369014785">0147XXXXXXXX4785</option>
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".
View 1 Replies
View Related
Jul 23, 2005
Trying to debug someone else's javascript code. There is a line that
looks like this:
req = req.substring(req.length-2, req.length);
From what I can gather in their comments, they want to capture the last two characters of the string "req".
I'm guessing that the above line won't do that, and they want to change it to
req = req.substring(req.length-1, 2);
In other words, the parameters are starting position, and length. Is that correct?
View 6 Replies
View Related
Jul 7, 2010
what will be the regular expression for this line:
Code JavaScript:
var id = $(this).attr("href").substring( $(this).attr("href").lastIndexOf('#'), $(this).attr("href").length);
Basically it gets the string after # in href attribute of clicked anchor tag.
View 3 Replies
View Related
Mar 8, 2011
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]
View 2 Replies
View Related
Feb 28, 2006
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.
View 1 Replies
View Related
Aug 28, 2009
I would like to assign the substring of particular text to a javascript variable so that I can use the variable in an if statement.
View 3 Replies
View Related
Jul 19, 2011
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.
here is what I have. Form
<form id="form" name="myForm" action="https:websiteSubmittingto.com" method="POST">
<label>inputfield1</label><br/><input type="text" name="inputfield1" style="width:150px;"/><br/>
[Code].....
I have tried putting a onsubmit on the form tag but that got me no where.
View 4 Replies
View Related
Feb 9, 2011
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!
View 6 Replies
View Related
Apr 28, 2011
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.
View 3 Replies
View Related
Apr 5, 2011
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]..
View 2 Replies
View Related
Oct 28, 2010
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?
View 6 Replies
View Related
Apr 19, 2010
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.
View 9 Replies
View Related
Mar 6, 2006
I have a script which gathers information from a form and, if needed, writes this info to a 'preview' window. At times {tokens} are used in place of real html tags. How can I tell the script to look for "{" and "}" and replace them, respectively, with "<" and ">".
I tried using "str = str.replace(/{/g, "<").replace(/}/g, ">");" but that didn't work. The script in question is being written by PHP... thus, may be generating a syntax-based failure. Any ideas?
View 14 Replies
View Related
Aug 28, 2006
Is it possible to delete a table and put another one in it's place, in the same document?
View 2 Replies
View Related
Jul 25, 2004
What I want, is the code to look for a particular ID of an img, and then change the filename (but not the whole path) of the image.
For instance...
if the path was "../images/headin.gif", the javascript would find this by the ID, and change to "headin" to "headdown".
I know I can do something like...
if(a.getAttribute("img").indexOf("headin")) {
but then I need to know how to replace "headin" with "headdown".
How can this be done?
(the reason I don't want to replace the whole src, as that would be very simple, is that the path of the image will change depending on the directory the page is in)
View 2 Replies
View Related
Jul 25, 2005
I'm trying to get my head around DOM and it's usefulness in designing web applications. Some of it is pretty straight forward, while some is kind of vague. What I am trying to do now is write data to a page. I want to fill in the data in the second span below.
<div> <span>Size</span> <span class="size"></span> </div>
I can write the data using the following.
var posSize = document.createTextNode(Ǝ'); parent.document.getElementById('size').appendChild(posSize);
But as the name suggests, it appends it to the current value. So every time I click something on the page and the value needs to reflect that item, it just appends it to the former value.
View 13 Replies
View Related
Jan 29, 2007
I got a javascript code that displays new text boxes when someone clicks on a button. Here is the code that goes into the header:
<script type="text/javascript">
boxct=0;
function dispMoreFiles() {
var upbox = "<INPUT name='numbers[]' TYPE='text' size=ཚ'><br>";
var updiv = document.getElementById("morefiles");
if (boxct<9) {
var addhtml = updiv.innerHTML+upbox;
updiv.innerHTML = addhtml;
boxct++;
} else {
alert('Message');
}}
</script>
I use this simple code in the body to make use of it:
<input type="text" name="numbers[]" size="30">
<div id="morefiles">
<input name="add" type="button" value="Click To Add Another Box">
Now, if I add another box, then type some text into it, then add another box, the box I just typed into is replaced with a new box, and a new box is added. How do I just make it add a new text box instead of replacing a current one?
View 14 Replies
View Related
Apr 19, 2002
I have a pitures folder with this format :
name_setnumber_picnumber.jpg
for ex: foo_1_02.jpg
how to write a function in JS to return the next and prev image names of the given name of the first image. ( foo_1_01.jpg and foo_1_03.jpg ).
View 4 Replies
View Related