|
|
|
Hi,
i like to disable the buttons on check of the checkbox....using Jquery
i have tried in 3 different ways...
1.attr("disabled", true)-- working in IE not in FF
2.attr("disabled", "disabled")- working in IE not in FF
3.attr("diabled") not working in both...
i want to know the property which is supported by all the browsers(like safari, chrome etc..)
thanks in advance
|
|
|
|
|
I suspect the problem is somewhere else. $('#id').attr('disabled',true) is working for me in FireFox, IE, Chrome and Opera. Setting it back to 'false' enables the inputs again.
|
|
|
|
|
I agree with graham
I tested with
below code:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<div>
<input type='checkbox' value='10' id='id'> <label for='id'>Test Checkbox</label>
</div>
<BUTTON onclick='a=!($("#id").attr("disabled")); $("#id").attr("disabled",a)'>
test
</BUTTON>
it work fine
|
|
|
|
|
If I will use <asp:button ...=""> and <asp: checkbox...=""> ....How can I disable checkbox
|
|
|
|
|
The code you are using has always worked for me so not sure what's wrong but as a point, the second one in your list is the correct one. If you are trying to enable the check boxes again you will have to use the removeAttr method as W3 standards say that the mere presence of the disabled attribute means the control is disabled, regardless of value (which some of the major browsers follow).
As for why your check boxes don't disable I can only suggest that IE and FF are handling your HTML differently (check Id's are the same, that you are only trying to set the disabled attribute after full page load (use $(document).ready if you aren't!) etc. etc.)
Hope this helps,
Ed
|
|
|
|
|
How can i use backbone.js.What is the purpose of backbone.js.Post some sample code.Actually i tried on google.I am not getting correct solution.
|
|
|
|
|
DeepthiTanguturi wrote: Actually i tried on google.
And you couldn't find this[^]?
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
|
I've hit a wall trying to use javascript to write a table with some image tags. I'm looping through an array of image names, then setting their src attribute. The function is creating the tags, but all that displays is the 'missing image' thumbnail. The function is fired via a button. Below is my code.
Thanks!
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional/EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="robots" content="noindex">
<title>Testing Javascript</title>
<script type="text/javascript">
function getImages() {
var allImages, vRow, vCell, vText, vImg;
var vCnt, i, j, x, y;
var vTable = document.createElement("TABLE");
var vTBody = document.createElement("TBODY");
vTable.appendChild(vTBody);
var images = new Array();
images[0] = "image1.jpg";
images[1] = "image2.jpg";
images[2] = "image3.jpg";
vCnt = images.length;
for (i=0; i < vCnt; i++)
{
vRow = document.createElement("TR");
vCell = document.createElement("TD");
var image = images[i];
vImg = document.createElement("IMG");
vImg.setAttribute("src", "images/" + image);
vCell.appendChild(vImg);
vRow.appendChild(vCell);
vTBody.appendChild(vRow);
}
var vTableContainer = document.getElementById("vTableContainer");
vTableContainer.appendChild(vTable);
}
</script>
</head>
<body bgcolor = "#FFFFFF">
<h2>Javascript and Images</h2>
<div id="parentDiv">
<p>
Trying to set the image source with js...
</p>
<div id="childDiv">
<form method="GET">
<input type="button" value="DISPLAY IMAGES" onClick="getImages();" />
</form>
</div>
<div id="vTableContainer"></div>
</div>
</body>
</html>
|
|
|
|
|
|
Dean, Thanks for the reply. I've been working with the jquery api just a bit today, and I really like it. Thanks for the reference!
|
|
|
|
|
Please vote if you found my answer useful.
thanks
|
|
|
|
|
I just checked about setAttribute. It seems that only Firefox implemented it properly.
JQuery is a very good choice. for your information you can also use
imgobject.src='my/image/source.jpg'; //it will do fine
|
|
|
|
|
(1) Please don't use names of collections for private vars
so var images = new Array();
better var arArrayOfImagesObjects=new Array();
images is al pre-dfined collection: document.images
see http://msdn.microsoft.com/en-us/library/ms537461.aspx
(2) To set scr:
valueof .src is not same like pure string
preload image
var imgObjekt1=new Image(); // height and width if you want
imgObjekt1.src='whatYouWant.jpg'; // maybe with path
vImg = document.createElement("IMG"); // check pionter !
if(vImg!=null)
{
// append into object (into child of body) // append into collection images automatically
// check pointer of appended object, use e.g. var imgAppendedImgObject
if(imgAppendedImgObject!=null)
{imgAppendedImgObject.src=imgObjekt1.src; // will be (now) rendered in body
// don't use setAttribute("src", "images/" + image);
}
}
(3) FIRST optimize your code during edit and THEN check errors at run time.
to createElement and appendChild
check always pointers != null
if you use a collection like images check too
declare vars inside of function --> local vars
declare vars inside of for{} --> declare 1 time outside of for and use inside
declare constants like "image1.jpg" outside of function --> use global code e.g. at begin of js-file (easy find and edit in js-file).
|
|
|
|
|
Would someone please tell me why this js won't display images in IE 7, but works perfectly in Firefox? I'm using Windows XP, and I've double-checked all my settings in IE 7. Thanks!
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Sample</TITLE>
<SCRIPT LANGUAGE="JavaScript">
window.onload = fnWrite;
function fnWrite()
{
// Declare variables
var vTable = document.createElement("TABLE");
var vTBody = document.createElement("TBODY");
var vRow, vCell, vDiv, vImg;
var i;
var images = new Array();
images[0] = "images/treble_f1.JPG";
images[1] = "images/treble_c1.JPG";
images[2] = "images/treble_d1.JPG";
images[3] = "images/treble_e1.JPG";
// Insert vBody into vTable
vTable.appendChild(vTBody);
// Insert a row
vRow = document.createElement("TR");
vTBody.appendChild(vRow);
vCell = document.createElement("TD");
vRow.appendChild(vCell);
// Insert images
for (i=0; i<images.length; i++)
{
vDiv = document.createElement("DIV");
vCell.appendChild(vDiv);
vImg = document.createElement("IMG");
vImg.src = images[i];
vImg.setAttribute("alt", "image");
vCell.appendChild(vImg);
}
// Insert the table
vTableContainer.appendChild(vTable);
}
</SCRIPT>
</HEAD>
<BODY>
<H1>Javascript Won't Work in IE 7</H1>
<div id="vTableContainer"></div>
</BODY>
</HTML>
|
|
|
|
|
Try moving the line
window.onload = fnWrite;
after the fnWrite() function block.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Thanks for the reply, however that did not fix this problem. The IE browser does display the little thumbnail box, which tells me the image tag is there, but this line of code
vImg.src = images[i];
for some reason is not setting the source for the image. I've even tried hard coding in the source with no luck.
|
|
|
|
|
Sorry, it was a bit of a stab in the dark, but I know that there are some strange inconsistencies between IE and the other browsers.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Thanks for the reply. Well, I removed the javascript from the HTML page and put it in a js file, and now it works. Go figure... Thanks a lot, Microsoft.
|
|
|
|
|
This[^] may help explain things.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
I've just tried your code with MS-IE7 on WXP and it works for me! I have a similar problem with code generated on the fly and displayed using IE.navigate using automation - the images come up with the red [x] box or the 4 symbol box but if I show the source, save it, run the saved version the images come up correctly. Are you using IE automation or simple file opening?
|
|
|
|
|
A massive problem of Microsoft
If you want reders animated gifs then that will by chrashed by Internet Explorer
preload img with '?' after suffix (:gif?) have no result: animated gif even not rendered.
e.g.
// X00 is an existing image object
// X01 is an existing preloaded image object with filled .src of an animated gif
X00.src=X01.src+'?'; // only if IE exists
X00.src=X01.src; // for opera etc.
preload image
var imgObjekt1=new Image(); // height and width if you want
imgObjekt1.src='animated.gif'; // maybe with path, but not with '?'
vImg = document.createElement("IMG"); // check pionter !
if(vImg!=null)
{
// append into object (into child of body) // append into collection images automatically
// check pointer of appended object, use e.g. var imgAppendedImgObject
if(imgAppendedImgObject!=null)
{imgAppendedImgObject.src=imgObjekt1.src+'?'; // will be (now) rendered in body in IE
}
}
|
|
|
|
|
Hi,
i am not able set the args.isValid as false for JS function...which is not having custom validator..
find the code below:
<asp:LinkButton runat="server" ID="btnApply" TabIndex="1" CssClass=" primary" OnClientClick = "return ApplyClick(this);" >
JS Code:
function Applyclick(args) {
if (errMsg != null) {
args.IsValid = false;
}
return false;
}
thanks in advance
modified 2-Feb-12 5:03am.
|
|
|
|