473,766 Members | 2,026 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

javascript:asp

63 New Member
Hi,

I have an application in which clicking on a checkbox should make rest of the checkboxes checked. its rather simple. I have never used Javascript before so i have no clue how to get through this.

here's my code.

this is the checkbox which on checked should make other check boxes checked.
Expand|Select|Wrap|Line Numbers
  1. <td >
  2. input <%If (Session("stateid") <> "") Then Response.Write("checked=""checked""") : Response.Write("")%> name="stateid" type="checkbox" class="body" id="stateid"   onclick="javascript:checkall(stateID);" value="checkbox" />
  3.                         All States.
  4. </td>
this is the code for other checkboxes(its in a loop)

Expand|Select|Wrap|Line Numbers
  1. <td                                  
  2.  <input <%For x = 0 to Ubound(Session("preferenceID"),1)%><%If (cInt(Session("preferenceID")(x)) = cInt((StateDDL.Fields.Item("stateID").Value))) Then Response.Write("checked=""checked""") : Response.Write("")%><%Next%> name="stateID"  type="checkbox" id="stateID" value="<%=(StateDDL.Fields.Item("stateID").Value)%>" />
  3.                                 <%=(StateDDL.Fields.Item("stateName").Value)%> </td>

and here's my javascript(i'm not sure how perfect this is)

Expand|Select|Wrap|Line Numbers
  1. <script type="text/JavaScript">
  2. function checkall(stateID) 
  3.  { 
  4.  
  5. stateID.Checked=true;
  6.  
  7. }
  8.  
  9. </script>
but this is doing nothing.please help.

Ayush
Sep 8 '08 #1
3 1709
DrBunchman
979 Recognized Expert Contributor
Hi Ayush,

Try using the following example to help you. The javascript function Check_All_Check Boxes loops through all the inputs in the specified span tag and checks them.
Expand|Select|Wrap|Line Numbers
  1. <script type="text/JavaScript">
  2. function Check_All_CheckBoxes()
  3. {
  4. var span = document.getElementById('spanCheckBoxes');
  5. var chk
  6. var chks= span.getElementsByTagName('input');
  7. for (var i=0, len=chks.length; i<len; i++)
  8.    {
  9.    chk= chks[i];
  10.    chk.checked = 1;
  11.    }
  12. }
  13. </script>
  14.  
  15. <td >
  16. <input type="checkbox" onclick="Check_All_CheckBoxes();" value="checkbox">All States.</input>
  17. </td>
  18.  
  19. <td>
  20.    <span id='spanCheckBoxes'>
  21.    <%
  22.    For x = 0 to 10
  23.       %>
  24.       <input name="stateID"  type="checkbox" value="<%=x%>" ><%=x%></input>
  25.       <%
  26.    Next
  27.    %>
  28.    </span>
  29. </td>
  30.  
Do you see how this works? Let me know how you get on.

Dr B

PS Please remember to use code tags to surround your code blocks.
Sep 9 '08 #2
ayush patel
63 New Member
Thanks a lot that worked.

Ayush.
Sep 9 '08 #3
DrBunchman
979 Recognized Expert Contributor
No problem, glad you got it working.

Dr B
Sep 10 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
2318
by: Chris Kennedy | last post by:
I am writing the value from a textarea input box to a cookie. Long story but when I return to the page I want to pull the value from the cookie and put it back in the textbox. When I do this all the linebreaks and spaces are removed. Here is the longer version of the problem if it helps. Essentially I have a page which sends some form infomation to an ASP page via sometimes a querystring and sometimes a form. This can happen several...
1
1462
by: Andrew Poulos | last post by:
I've written some ASP using javascript (rather than vbscript) and it runs as expected on my test IIS server. Recently a colleague said that he was unsure if an Apache server, that's setup to serve ASP, can correctly handle non-vbscript ASP. Does anyone know one way or the other? Andrew Poulos
4
12416
by: KK | last post by:
Hi, Does anybody know how to call server side function in javascript? Suppose I've a method named Test() at code behind of ASP.Net page. How can I call that method in javascript function ??? Any help is appreciated..
5
5376
by: Anon | last post by:
Since installing the security update http://www.microsoft.com/downloads/details.aspx?familyid=16DD21A1-C4EE-4ECA-8B80-7BD1DFEFB4F8&displaylang=en on our Windows 2000 server (SP4) all ASP pages which utilise Javascript have stopped working with the following error Active Server Pages error 'ASP 0129' Unknown scripting language /whateverfile.asp, line 2 The scripting language 'JavaScript' is not found on the server.
1
2785
by: JimmyFo | last post by:
Hi, this is a bit complicated but maybe someone can help here. I have an ASP.Net 2.0 page with a JavaScript file selector. I did this because I wanted to be able to select multiple files at a time. Here's a quick preview of the JS and ASP to show you what it looks like: ASP <td style="width:30%"><asp:FileUpload ID="fileBox" runat="server" /> <asp:Button ID="grabFile" Text="Submit" runat="server" /></td>
3
1223
by: ashima515 | last post by:
Hi... M a newbe to asp.net. I am trying to use a javascript function in my asp.net page. The function works fine but for the second time. I have made a function that displays an alert box. but wen i click the button for the first time nothing happens but on second click the alert box is displayed. y so? here's the code: Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click ...
2
1314
by: RevJPZ | last post by:
I have a JavaScript function that is opening a new ASP page in a window with specific parameters. I want to pass information from the first page to the second. I can easily simulate the "post" method in ASP by adding the information to the URL/QueryString but I don't want the information displayed in the URL. Is there any other way to pass the information from a form to a new window via JavaScript?
3
5590
by: TheLymner | last post by:
I have, what I believe, is a rather simple question. However, I cannot find the answer anywhere on the web nor in any of the library of xml or javascript/asp books available. How do I pass and store an xml element data (an interger) into a javascript/asp variable? I am not going to display the data (that I can do easily), rather the data is going to used to deteremine how the rest of the parent data is going to be displayed in any of 90...
2
2121
by: ublow56 | last post by:
I am trying to create an ASP application using javascript. I found may ways to connect to Ms Access using VBScript, but I can't find any for the Javascript... Can someone help me??? I just need the simpliest coding (using ASP server-side javascript) to connect to MS Access. Thank you!!!!
0
9568
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10008
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9837
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8833
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7381
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6651
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3929
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3532
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2806
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.