I tired to apply .trim() in javascript for one of my code. it's working fine under mozilla, but error display once I tried in IE8, does anyone know what is going on here? anyway I can make it work in IE?
code:
var ID = document.getElementByID('rep_id').value.trim();
error display:
Message: Object doesn't support this property or method
Line: 604
Char: 2
Code: 0
URI: http://test.localhost/test.js
hi everybody...
I need a javascript code that split a string like below:
Input string: "a=aa| b=b||b | c=cc"
Output:
a=>aa
b=>b||b
c=>cc
I'd written different codes like:
split(/ \ | /)
or
Split(/ \| (?! \ |) /)
but didn't work.
please help me...
I really need it fast.
I need some help finding the error in my javascript calculation.
I need to calculate the sum of my input boxes automatically and have my user be able to edit the calculation using + or - buttons.
The code I have already does the calculation automatically if you manually enter the numbers, but pressing the + or - does not change the calculation.
Here is the code:
<html>
<head>
<script language="javascript">
function Calc(className){
var elements = document.getElementsByClassName(className);
var total = 0;
for(var i = 0; i < elements.length; ++i){
total += parseInt(elements[i].value);
}
document.form0.total.value = total;
}
function addone(field) {
field.value = Number(field.value) + 1;
}
function subtractone(field) {
field.value = Number(field.value) - 1;
}
</script>
</head>
<body>
<form name="form0" id="form0">
1: <input type="text" name="box1" id="box1" class="add" value="0" onKeyUp="Calc('add')" onChange="updatesum()" onClick="this.focus();this.select();" />
<input type="button" value=" + " onclick="addone(box1);">
<input type="button" value=" - " onclick="subtractone(box1);">
<br />
2: <input type="text" name="box2" id="box2" class="add" value="0" onKeyUp="Calc('add')" onClick="this.focus();this.select();" />
<input type="button" value=" + " onclick="addone(box2);">
<input type="button" value=" - " onclick="subtractone(box2);">
<br />
3: <input type="text" name="box3" id="box3" class="add" value="0" onKeyUp="Calc('add')" onClick="this.focus();this.select();" />
<input type="button" value=" + " onclick="addone(box3);">
<input type="button" value=" - " onclick="subtractone(box3);">
<br />
<br />
Total: <input readonly style="border:0px; font-size:14; color:red;" id="total" name="total">
</form>
</body></html>
Im sure the issue must be small, I just cant put my finger on it.
I am trying to build a regular expression in javascript that checks for 3 word characters however 2 of them are are optional. So I have:
/^\w\w\w/i
what I am stumped on is how to make it that the user does not have to enter the last two letters but if they do they have to be letters
I know how to add to clipboard with JavaScript, but what I want now is TechCrunch clipboard trick;
when someone copies some text ( ctrl+c, right click copy, clicking on a copy link on-site ), additional text is added to the clipboard ( like "this text was copied from ... ).
I know they use Tynt, but don't really know is this a feature you get with it or custom coded?
I tried some "add to favorties" JavaScript scripts.. With IE8, I get an "access denied" (is that even possible to add a bookmark via JS with IE8?) and it just doesn't work with IE6...
Anybody has a good script that works on most browsers?
Thanks!
Hi, i am detecting images on my webpage with javascript document.images function which returns an rray of images. Is there any way to get the mime type of the image from this since i am not using any extension names on images which are loading?
I have this small JavaScript code which I need some help with:
function doFocus(text) {
if (text.value == "Enter Name") {
text.value = "Student Name -";
}
}
All I need here is when someone clicks on my textbox, the text "Student Name -" should change its color, and should text-align = left. I am looking for the appropriate syntax for something like text.color and text.align.
Hi everyone,
I'm looking to find the Javascript Event I need to put into jQuery's .bind function in order to have the function triggered when a selection is made from a <select> element.
At the moment I'm using .bind('change',function() { ...}) but I need the event to trigger when the selected option is chosen again.
Any suggestions?
I want to know is it possible to insert additional text in HTML elements using jquery or javascript?
If there is already a text "Down" in paragraph elements, then I just want to append text "full", so that it would be "Down full". Is this possible? Which method should I use?
What is the difference (if any) between the javascript strings defined below?
var str1 = "Somestring";
var str2 = 'Somestring';
"" and '' mean two very different things to me predominantly writing code in C++ :-)
EDIT: If there is no difference why are there two ways of achieving the same thing and which is considered better practice to use and why. Thanks!
I am not familiar with javascript and I have had some exposure to java but I found a web application that fits the goals of my app perfectly. The owner has provided the source by viewing the source in the html and I was wondering how hard it would be to reuse the code to deploy a similar app.
How can i handle a link which doesn't have a id, it just has a classname like "classbeauty".
Now i need to know if a user has clicked the link.
If the link is clicked i just need to call the alert("yes link clicked");
I don't know how to handle events in Javascript.
How can i do that?
I have a long task in Javascript that should be performed before the web page content is displayed. During the execution of this task I would like to show an image whose opacity will grow up to 100% (when the task is done).
How this can be achieved ?
I'm trying to clean some html text with javascript, there are white spaces included before and after some words (text is poorly formatted).
Currently I have this regex:
$("#" + target + " *").replaceText(/([\S][\u05B0-\u05C4]*)/gi, '<span class="marked">$1<\/span>');
This will capture all the non white-space characters and wrap them in a span element, but will not capture spaces between words (I need the span).
How would you solve this?
Hi, i'm pretty new to Javascript and PHP so please bear with me if i'm asking some really dumbed down questions.
Ok, say i need to use values stored in a PHP $_GET or $_SESSION, is it advisable to just do something like
var something = PHP echo $_SESSION or $_GET
I have unix timestamps from time zone X which is not known,
the current timestamp(now()) in TZ X is known 1275143019,
how to approach a javascript function so that it can generate the datetime in the users current TZ in the format 2010-05-29 15:32:35 ?
How expensive are local variables (var v), global variables (window.v) and cross-global variables (parent.v) in JavaScript, in the major browsers? Has anyone performed any good tests on this one?
To reduce http request i want to mix multiple jquery plugin's javascript filesa and main jquery file into one.
What things should be considered?
Do we just need to place code from all files into new file one bye one or need to do something more. ?
How do I test to see if links are external or internal? Please note:
I cannot hard code the local domain.
I cannot test for "http". I could just as easily be linking to my own site with an http absolute link.
I want to use jQuery / javascript, not css.
I suspect the answer lies somewhere in location.href, but the solution evades me.
Thanks!
Hello,
Is there a simpler way to rewrite the following condition in JavaScript ?
Thanks !
if ((x == 1) || (x == 3) || (x == 4) || (x == 17) || (x == 80)) {...}
Hello,
I'm trying to update values from a xml file into textboxes. I have this javascript being called in the Page_Load event
this.Page.ClientScript.RegisterStartupScript(this.GetType(), "Script", sb.ToString(), true);
I click the continue button which does a post back but the values are not updated until I refresh the page again which makes me think the js isn't being run until after the page is returned. I'm wondering how to have the values updated when the page is refreshed after the button postback.
thanks