|
Check this out. I find it to be extremely peculiar and very frustrating. I've downloaded a few scripts to check all of the checkboxes in a form. All of them have had the same issue. When I have one value for a checkbox, the function to check all no longer works. When I have more than one value for the checkbox, it works. Take the code below as an example. If you click the "Check All" button, it's not working. Yet, take the line of HTML that has the checkbox, copy it to the line after, reload and click the button again. It will work! What kind of crazy voodoo is this? One checkbox value isn't valid or something?
<HTML>
<head>
<SCRIPT LANGUAGE="JavaScript">
<!--
<!-- Begin
function checkAll(field)
{
for (i = 0; i < field.length; i++)
field[i].checked = true ;
}
function uncheckAll(field)
{
for (i = 0; i < field.length; i++)
field[i].checked = false ;
}
</script>
</head>
<body>
Here is the HTML:
<form name="myform" action="checkboxes.asp" method="post">
<b>Your Favorite Scripts & Languages</b><br>
<input type="checkbox" name="list" value="1">Java<br>
<input type="button" name="CheckAll" value="Check All" onClick="checkAll(document.myform.list)">
<input type="button" name="UnCheckAll" value="Uncheck All" onClick="uncheckAll(document.myform.list)">
<br>
</form>
</body>
</html>
|
|
|
|
|
Hehe hehe.
Cool. Didn't know that before - that's a neat thing you've just taught me.
When there is only one check-box, "document.myform.list" points to a checkbox item. When there's more than one, it points to an _array of_ checkbox items. Since ".length" is for use on arrays, it fails and returns "undefined" when called on an any var that's not an array.
Simply put, all you have to do is check the return value of "field.length". If it doesn't have one, then you're dealing with a single item. Otherwise, you're dealing with an array of items.
Here, try this on for size:
function checkAll(field)
{
if (!field.length)
field.checked = true;
else
for (i = 0; i < field.length; i++)
field[i].checked = true ;
}
function uncheckAll(field)
{
if (!field.length)
field.checked = false;
else
for (i = 0; i < field.length; i++)
field[i].checked = false;
}
|
|
|
|
|
You just blew my mind. Thanks for that!
|
|
|
|
|
A true pleasure - one good turn deserves another...
I'd been meaning to get around to investigating how to check all the check-boxes on a page.
If you haven't got them already, you should consider getting the firebug plugin (and its 'friends') for firefox.
|
|
|
|
|
You check only one check box then dont use for loop. Use for particular Id to check the value. More then one check box then to use your code.Because of only one check box then return the value is undefined only.
modified on Friday, October 30, 2009 9:00 AM
|
|
|
|
|
Thanks for your thoughts. Just a quick question:
Which would you rather do?
a) Write 1 piece of JavaScript and include it in server generated html
b) Keep track of the number of check boxes generated on the server before emitting the appropriate piece of JavaScript?
Never mind what happens when you throw ajax into the equation, and the user may alter the number of check-boxes after the page has been served....
|
|
|
|
|
Hi,
We have a website hosted on godaddy. They have provided us the control panel login. Our project has a home page called "Home.aspx". By default , when the website opens up, it looks for a default.aspx page. So we wrote a simple javascript to transfer the page to home.aspx from a default.aspx page.
Unfortunately, since this is a product based website, google refused to index the website because it "doesn`t like redirects". So the only option left is we change the home.aspx to default.aspx, but it would call for a huge change in the already built up project.
The other option, we thought, would be asking godaddy to change the default document in their IIS. We called in the support, but "Its not possible" is the only answer we received.
If anyone here uses godaddy, where do we find the option for changing the default document in the control panel????
Any other solution is welcomed.
When you fail to plan, you are planning to fail.
|
|
|
|
|
That really is pants. GoDaddy should be able to change that in seconds. Guess it leaves you with 3 options:
1) rename the Home.aspx to default and fix all links.
2) Just duplicate the home page and rename it to "default" (have two home pages)
3) Switch web host
|
|
|
|
|
hi
iam using CR to export reports to PDF in a web application, everything in the local computer is fine
but when i deployed the project ... when i click the print button on the
report and after clicking the OK button in the Print Options, a white screen appear
and nothing is happening
any suggestions ??
When you get mad...THINK twice that the only advice
Tamimi - Code
|
|
|
|
|
Is Crystal Reports installed on the webserver?
|
|
|
|
|
i installed only the runtime for CR, i can see the report and i can export it
to MSword, but the problem with the exporting to pdf.
When you get mad...THINK twice that the only advice
Tamimi - Code
|
|
|
|
|
Sound like one of the numerous bugs features of CR. Have you installed all applicable servicepacks and updates?
|
|
|
|
|
no, i found many many threads aboutnthis issue... but have no luck with a soluation
When you get mad...THINK twice that the only advice
Tamimi - Code
|
|
|
|
|
Crystal Report uses Javascript to achieve Export functionality, Check whether the javascripts files are all available in the server. Check in the aspnet_client folder.
N.Surendra Prasad
|
|
|
|
|
Hi i m editing the data using tinymce editor in that editor i have include the file which displays
submenu on the top but the problem is that the submenu is not working in tinymce it does not show submenu
i dont have any idea about tinymceeditor can anyone help me .is there any settings for that?
in asp(scripting language i m working).i dont know ajax.
|
|
|
|
|
Have you tried the vendors web site? I bet they have a support section
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
Hi friends,
I am facing a strange problem. I have written a browser plugin that inserts a js inside any webpage and does some modification (say font size increase/decrease). The problem is that after doing these modification when I print the page only first page gets printed and other appears blank.
This problem is occurring with very few websites e.g. wikipedia. Other sites get printed normally. I cant figure out whats the problem. Any help will be appreciated.
Thanks
|
|
|
|
|
Hii
There are many tools available to synchronize with various calendars..
Among all what is the commmon principle or startegy used to integrate inside a personal Calendar .......
with warm regards.....
Pradeep
|
|
|
|
|
I am trying to host WCF web-service on GoDaddy.com, where I have web-site hosted in A-virtual directory and web-service hosted in B-virtual directory. Now, I am trying to access the files available in A-virtual directory from web service that is hosted on B-virtual directory and it gives me access denied error. But, If I copy the same files in B-virtual directory, I am able to access those files from web-service.
Now the question is, it's GoDaddy that is restricting this?? Can I solve this problem through code? If Yes, How? Or Do I need to contact GoDaddy to do it?? Or Do I need to purchase different kind of hosting account??
Thanks in advance.
|
|
|
|
|
chirag_chauhan wrote: Now the question is, it's GoDaddy that is restricting this??
Did you ask them?
|
|
|
|
|
You'd think that is a good question, but I have proven many times that they are liars, or just plain have no idea what it is they restrict.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
I need to know what cookies use certain web site.
I heard about HTTP Header plugin , that can show all HTTP headers during site browsing, form submission, etc. But cannot find it at the moment.
Or maybe exist any other solutions ?
Thanks
|
|
|
|
|
progman wrote: But cannot find it at the moment.
Where was it the lats time you had it?
|
|
|
|
|
Hi guys!
I can't figure out what the heck I'm doing wrong. I'm making a (hoping to at least) simple function that will take a white border and fade it to black on a mouseOver. Here's what I have so far:
<script type="text/javascript">
function animation(object, direction, number) {
if (!number) {
if (direction == "out") number = 255;
if (direction == "in") number = 0;
}
var color = "rgb(" + number + "," + number + "," + number + ")";
object.style.borderColor = color;
if (direction == "out") {
if (number == 0) return;
var newNumber = number - 1;
window.setTimeout(animation(object, direction, newNumber), 500);
}
if (direction == "in") {
if (number == 255) return ;
var newNumber = number + 1;
window.setTimeout(animation(object, direction, newNumber), 500);
}
}
</script>
Now, what happens (when I use the debugger in visual studio 2008), the function executes correctly until the number variable gets to 255. At 255, the system does see the if (number == 255) return; part and appears to execute it. What happens after that when I hit F11 to continue stepping into the code, it jumps down to the window.setTimeout line again and tell's me there's an invalid argument. What's really weird, is that the number variable has now gone back to 254! I've even tried changing the if statement to stop at 250 and other various numbers, but it still seems to subtract a number and then give me the failure insted of stopping execution. Looking at other setTimeout examples, I also tried different syntax including wrapping the function in quotes, but this is the only way I've been able to get it to actually call the function. Wrapping it in quotes seems to just jump to the next line and return. I'm still fairly new to javascript, so I wouldn't doubt that there's something wrong with the flow of my logic, but I'm to the point where I feel like I'm not getting anywhere. Hopefully another set of eyes might see what's not obvious to me.
Thanks!
Knowledge is not power, however, the acquisition and appropriate application of knowledge can make you a very powerful individual.
|
|
|
|
|
window.setTimeout needs a function-"pointer" as first argument. If I'm right this can only be a function without arguments.
window.setTimeout(animation, 500); <- rigth way
window.setTimeout(animation(object, direction, newNumber), 500); <- wrong
Starts the function animation direct without waiting 500ms.
|
|
|
|