Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. javascripting with web controls

javascripting with web controls

Scheduled Pinned Locked Moved ASP.NET
javascripthtmlquestion
23 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K kashasd

    // Outside the Datagrid //this example is having two radiobuttons named with male, female and // check box below the radiobuttons function validate(form) { // Checking if at least one period button is selected. Or not. if (!document.form1.sex[0].checked && !document.form1.sex[1].checked){ alert("Please Select Sex"); return false;} if(!document.form1.agree.checked){alert("Please Read the guidelines and check the box below"); return false; } return true; }

    kishore kumar Manikonda Software Developer

    I Offline
    I Offline
    iamdking
    wrote on last edited by
    #3

    But what abt checkboxes within datalist. How to write script on checkbox within dataslit?

    1 Reply Last reply
    0
    • K kashasd

      // Outside the Datagrid //this example is having two radiobuttons named with male, female and // check box below the radiobuttons function validate(form) { // Checking if at least one period button is selected. Or not. if (!document.form1.sex[0].checked && !document.form1.sex[1].checked){ alert("Please Select Sex"); return false;} if(!document.form1.agree.checked){alert("Please Read the guidelines and check the box below"); return false; } return true; }

      kishore kumar Manikonda Software Developer

      B Offline
      B Offline
      bernie_011
      wrote on last edited by
      #4

      Hello programmers, Any idea how to compute two time value in two textbox and display in label? Bernie

      C 1 Reply Last reply
      0
      • B bernie_011

        Hello programmers, Any idea how to compute two time value in two textbox and display in label? Bernie

        C Offline
        C Offline
        Chetan Ranpariya
        wrote on last edited by
        #5

        Hi Can you elaborate your exact requirement?

        Thanks and Regards, Chetan Ranpariya

        B 1 Reply Last reply
        0
        • C Chetan Ranpariya

          Hi Can you elaborate your exact requirement?

          Thanks and Regards, Chetan Ranpariya

          B Offline
          B Offline
          bernie_011
          wrote on last edited by
          #6

          i have 2 time dropdownlist, frmdrp and todrp, i just add collection to dropdown which is 8:30,9:00,9:30,10:00(completed to 24 hours) For example i have selected 8:30 from the frmdrp then i select 12:30 from todrp. After postback, the label will show the difference between the two time selected. The result is: label1="4" hour difference. Can you help me with that? Bernie

          C 1 Reply Last reply
          0
          • B bernie_011

            i have 2 time dropdownlist, frmdrp and todrp, i just add collection to dropdown which is 8:30,9:00,9:30,10:00(completed to 24 hours) For example i have selected 8:30 from the frmdrp then i select 12:30 from todrp. After postback, the label will show the difference between the two time selected. The result is: label1="4" hour difference. Can you help me with that? Bernie

            C Offline
            C Offline
            Chetan Ranpariya
            wrote on last edited by
            #7

            Hi, You can use the following logic if it is applicable to your requirments. DateTime dt1 = Convert.ToDateTime(frmdrp.SelectedValue); DateTime dt2 = Convert.ToDateTime(todrp.SelectedValue); TimeSpan ts = dt2 - dt1; int totalhours = ts.Hours; int totalmins = ts.Minutes; label1.Text = totalhours.ToString() + ":" + totalmins.ToString(); I hope this will help you. Thanks and Regards, Chetan Ranpariya -- modified at 5:19 Monday 30th April, 2007

            B 2 Replies Last reply
            0
            • C Chetan Ranpariya

              Hi, You can use the following logic if it is applicable to your requirments. DateTime dt1 = Convert.ToDateTime(frmdrp.SelectedValue); DateTime dt2 = Convert.ToDateTime(todrp.SelectedValue); TimeSpan ts = dt2 - dt1; int totalhours = ts.Hours; int totalmins = ts.Minutes; label1.Text = totalhours.ToString() + ":" + totalmins.ToString(); I hope this will help you. Thanks and Regards, Chetan Ranpariya -- modified at 5:19 Monday 30th April, 2007

              B Offline
              B Offline
              bernie_011
              wrote on last edited by
              #8

              Can you please do the code in visual basic not in C# code? Thanks and God Bless! Bernie

              1 Reply Last reply
              0
              • C Chetan Ranpariya

                Hi, You can use the following logic if it is applicable to your requirments. DateTime dt1 = Convert.ToDateTime(frmdrp.SelectedValue); DateTime dt2 = Convert.ToDateTime(todrp.SelectedValue); TimeSpan ts = dt2 - dt1; int totalhours = ts.Hours; int totalmins = ts.Minutes; label1.Text = totalhours.ToString() + ":" + totalmins.ToString(); I hope this will help you. Thanks and Regards, Chetan Ranpariya -- modified at 5:19 Monday 30th April, 2007

                B Offline
                B Offline
                bernie_011
                wrote on last edited by
                #9

                i got it..Thank yo very much i used DIM something like that. God Bless you boy.. Ahh.. I have another question, How can i insert multiple items from listbox in my table in database? I have a category "Agents" on dropdownlist, I have may names on my listbox, If i click Insert it only insert 1 row not all the items inside my listbox. Bernie

                C 1 Reply Last reply
                0
                • B bernie_011

                  i got it..Thank yo very much i used DIM something like that. God Bless you boy.. Ahh.. I have another question, How can i insert multiple items from listbox in my table in database? I have a category "Agents" on dropdownlist, I have may names on my listbox, If i click Insert it only insert 1 row not all the items inside my listbox. Bernie

                  C Offline
                  C Offline
                  Chetan Ranpariya
                  wrote on last edited by
                  #10

                  Hi, You can do it like this. ListItem litem = new ListItem(); litem.Text = drp.SelectedText; litem.Value = drp.SelectedValue; lstbox.Items.Add(litem); The code above is the logic and you can implement in VB easily. Just syntax is the difference. Thanks and Regards, Chetan Ranpariya

                  B 1 Reply Last reply
                  0
                  • C Chetan Ranpariya

                    Hi, You can do it like this. ListItem litem = new ListItem(); litem.Text = drp.SelectedText; litem.Value = drp.SelectedValue; lstbox.Items.Add(litem); The code above is the logic and you can implement in VB easily. Just syntax is the difference. Thanks and Regards, Chetan Ranpariya

                    B Offline
                    B Offline
                    bernie_011
                    wrote on last edited by
                    #11

                    How can i insert all the items in listbox into the database? multiple insert. I can get all the items but its just inserting 1 row in that category. drpcategory : Agent,Trainees drpNames : Bernie, Ray,Kirby,John,Beejay list1 : contains all the selected items on drpNames table1 : my table in my database my query now is INSERT INTO table1(Category,Name)VALUES(@category,@name) If list1box1 contains all the items from drpnames and i select "Agent" category on my drpcategory and i click the button insert, all the 4 items will be inserted in my database table(table1) on a single click. Can you help me with that? I am using detailsView and SQLdatasource Bernie Leynes

                    C 1 Reply Last reply
                    0
                    • B bernie_011

                      How can i insert all the items in listbox into the database? multiple insert. I can get all the items but its just inserting 1 row in that category. drpcategory : Agent,Trainees drpNames : Bernie, Ray,Kirby,John,Beejay list1 : contains all the selected items on drpNames table1 : my table in my database my query now is INSERT INTO table1(Category,Name)VALUES(@category,@name) If list1box1 contains all the items from drpnames and i select "Agent" category on my drpcategory and i click the button insert, all the 4 items will be inserted in my database table(table1) on a single click. Can you help me with that? I am using detailsView and SQLdatasource Bernie Leynes

                      C Offline
                      C Offline
                      Chetan Ranpariya
                      wrote on last edited by
                      #12

                      Hi, If you are creating seperate row for each of the item in the listbox then you have to loop through all the items and create intsert query in the loop and execute it.

                      Thanks and Regards, Chetan Ranpariya

                      B 1 Reply Last reply
                      0
                      • C Chetan Ranpariya

                        Hi, If you are creating seperate row for each of the item in the listbox then you have to loop through all the items and create intsert query in the loop and execute it.

                        Thanks and Regards, Chetan Ranpariya

                        B Offline
                        B Offline
                        bernie_011
                        wrote on last edited by
                        #13

                        it works fine if i use dropdownlist, but in dropdownlist you will insert the data in the database individually right?. I want to use listbox for me to insert all the data in a single click of the button. God Bless you! Bernie Leynes

                        C 1 Reply Last reply
                        0
                        • B bernie_011

                          it works fine if i use dropdownlist, but in dropdownlist you will insert the data in the database individually right?. I want to use listbox for me to insert all the data in a single click of the button. God Bless you! Bernie Leynes

                          C Offline
                          C Offline
                          Chetan Ranpariya
                          wrote on last edited by
                          #14

                          HI, I am not getting you exact requirement. Can you pelase elaborate by giving an example? Thanks and Regards, Chetan Ranpariya

                          B 1 Reply Last reply
                          0
                          • C Chetan Ranpariya

                            HI, I am not getting you exact requirement. Can you pelase elaborate by giving an example? Thanks and Regards, Chetan Ranpariya

                            B Offline
                            B Offline
                            bernie_011
                            wrote on last edited by
                            #15

                            ok. heres my example I have 2 dropdown and a listbox and a table in my database drpcategory drpNames listbox1 table1- the columns are Category,Name I have items in drpcategory. the items are: Agent, Trainees In my drpNames the items are : Bernie, Ray, Kirby listbox1.items= drpNames.selecteditem.text If my listbox1 contains all the names from drpNames and i select "Agent" from drpCategory then i click insert button all the 3 names on my listbox will be inserted but different row. The result will be Category Name Agent Bernie Agent Ray Agent Kirby My problem is even if i have multiple items in my listbox then after i click insert int only insert 1 row in my table which is the first row only Bernie Leynes

                            C 1 Reply Last reply
                            0
                            • B bernie_011

                              ok. heres my example I have 2 dropdown and a listbox and a table in my database drpcategory drpNames listbox1 table1- the columns are Category,Name I have items in drpcategory. the items are: Agent, Trainees In my drpNames the items are : Bernie, Ray, Kirby listbox1.items= drpNames.selecteditem.text If my listbox1 contains all the names from drpNames and i select "Agent" from drpCategory then i click insert button all the 3 names on my listbox will be inserted but different row. The result will be Category Name Agent Bernie Agent Ray Agent Kirby My problem is even if i have multiple items in my listbox then after i click insert int only insert 1 row in my table which is the first row only Bernie Leynes

                              C Offline
                              C Offline
                              Chetan Ranpariya
                              wrote on last edited by
                              #16

                              hi, See in this case the solution is what I have told you before. U have to loop through all the items in the listbox and create INSERT query for each of the item and execute it. Can u send the code you have written?

                              Thanks and Regards, Chetan Ranpariya

                              B 1 Reply Last reply
                              0
                              • C Chetan Ranpariya

                                hi, See in this case the solution is what I have told you before. U have to loop through all the items in the listbox and create INSERT query for each of the item and execute it. Can u send the code you have written?

                                Thanks and Regards, Chetan Ranpariya

                                B Offline
                                B Offline
                                bernie_011
                                wrote on last edited by
                                #17

                                listbox1.items = drpNames.selecteditem.text this is how i get the items from dropdown and display in listbox. How can i Loop all the items from listbox? If i do looping it will insert all the items from listbox in my table in the database? Bernie Leynes

                                C 1 Reply Last reply
                                0
                                • B bernie_011

                                  listbox1.items = drpNames.selecteditem.text this is how i get the items from dropdown and display in listbox. How can i Loop all the items from listbox? If i do looping it will insert all the items from listbox in my table in the database? Bernie Leynes

                                  C Offline
                                  C Offline
                                  Chetan Ranpariya
                                  wrote on last edited by
                                  #18

                                  Hi, The onel line of code u have given will not execute coz it will give compile time error. yes i u loop through all items in the listbox it will all the items from the listbox in the table in database. how do u try to insert data in the table in you database? Please paste your code here. Thanks and Regards, Chetan Ranpariya

                                  B 2 Replies Last reply
                                  0
                                  • C Chetan Ranpariya

                                    Hi, The onel line of code u have given will not execute coz it will give compile time error. yes i u loop through all items in the listbox it will all the items from the listbox in the table in database. how do u try to insert data in the table in you database? Please paste your code here. Thanks and Regards, Chetan Ranpariya

                                    B Offline
                                    B Offline
                                    bernie_011
                                    wrote on last edited by
                                    #19

                                    Heres my code.. INSERT INTO table1(category,Name)VALUES(@category,@name) category bind to drpcategory name bind to listbox1 You are blessed men. Thanks Bernie Leynes

                                    1 Reply Last reply
                                    0
                                    • C Chetan Ranpariya

                                      Hi, The onel line of code u have given will not execute coz it will give compile time error. yes i u loop through all items in the listbox it will all the items from the listbox in the table in database. how do u try to insert data in the table in you database? Please paste your code here. Thanks and Regards, Chetan Ranpariya

                                      B Offline
                                      B Offline
                                      bernie_011
                                      wrote on last edited by
                                      #20

                                      I know you know how to do that man. Please help me.. Thanks and God Bless Bernie

                                      C 1 Reply Last reply
                                      0
                                      • B bernie_011

                                        I know you know how to do that man. Please help me.. Thanks and God Bless Bernie

                                        C Offline
                                        C Offline
                                        Chetan Ranpariya
                                        wrote on last edited by
                                        #21

                                        HI, I have asked you to paste your whole code here. but I dont think you want to do that. You are just pasting one or two lines and want me to do everything for you. Things doesnt happen like that. If you want to insert values from the listbox the commong logic is that you take items from the listbox one by one and create insert query for each of the item and execute the query. foreach(ListItem LI in lstbox.Items) { string strquery = "Insert Into table Values ('" + ddl.SelectedValue + "', '" + LI.Value + "')"; cmd.executenonquery(strquery); } THis is the commong logic. You implement this as per your requirement. If any further assistance is needed then do reply with the whole code u have written to insert the data in the table. Thanks and Regards, Chetan Ranpariya

                                        B 2 Replies Last reply
                                        0
                                        • C Chetan Ranpariya

                                          HI, I have asked you to paste your whole code here. but I dont think you want to do that. You are just pasting one or two lines and want me to do everything for you. Things doesnt happen like that. If you want to insert values from the listbox the commong logic is that you take items from the listbox one by one and create insert query for each of the item and execute the query. foreach(ListItem LI in lstbox.Items) { string strquery = "Insert Into table Values ('" + ddl.SelectedValue + "', '" + LI.Value + "')"; cmd.executenonquery(strquery); } THis is the commong logic. You implement this as per your requirement. If any further assistance is needed then do reply with the whole code u have written to insert the data in the table. Thanks and Regards, Chetan Ranpariya

                                          B Offline
                                          B Offline
                                          bernie_011
                                          wrote on last edited by
                                          #22

                                          im sori but i am using SQLDataSource thats why i have only one line of Code. I just bind the listbox on my textfield. I did not use the manual connection in code behind. Any idea about that?. I already check the multiple selection but still insert 1 data per transaction thank you Bernie

                                          1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups