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. Can anybody help me to use combobox from Javascript function [modified]

Can anybody help me to use combobox from Javascript function [modified]

Scheduled Pinned Locked Moved ASP.NET
helpjavascriptcom
6 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.
  • I Offline
    I Offline
    indian143
    wrote on last edited by
    #1

    Post back is the only problem for me I dont want to use it. I want to display a Date field with three combo boxes. When month and year are selected, automatically the days combo must me filled with those many number of days according to leap or not and then 31 or 30 like that. I want to do all this stuff using Javascript function. So please help me if any body could do it. Thank you.

    S/W Engineer Akebono Soft Technologies aleem_abdul@akebonosoft.com.

    V M 2 Replies Last reply
    0
    • I indian143

      Post back is the only problem for me I dont want to use it. I want to display a Date field with three combo boxes. When month and year are selected, automatically the days combo must me filled with those many number of days according to leap or not and then 31 or 30 like that. I want to do all this stuff using Javascript function. So please help me if any body could do it. Thank you.

      S/W Engineer Akebono Soft Technologies aleem_abdul@akebonosoft.com.

      V Offline
      V Offline
      Venkatesh Mookkan
      wrote on last edited by
      #2

      Try this javascript man...

      function GetDayOfMonth(DayCtrlName, MonthCtrlName, YearCtrlName){
      var DayCtrl=document.getElementById(DayCtrlName);
      var MonthCtrl=document.getElementById(MonthCtrlName);
      var YearCtrl=document.getElementById(YearCtrlName);
      var lastDayValue=DayCtrl.value;
      var DaysCount=31;
      if (MonthCtrl.options[MonthCtrl.selectedIndex].value=='2' &&
      (parseInt(YearCtrl.options[YearCtrl.selectedIndex].value)%4)==0){
      DaysCount=29;
      }else if (MonthCtrl.options[MonthCtrl.selectedIndex].value=='2'){
      DaysCount=28;
      }else if (MonthCtrl.options[MonthCtrl.selectedIndex].value=='4' ||
      MonthCtrl.options[MonthCtrl.selectedIndex].value=='6' ||
      MonthCtrl.options[MonthCtrl.selectedIndex].value=='9' ||
      MonthCtrl.options[MonthCtrl.selectedIndex].value=='11'){
      DaysCount=30;
      }
      DayCtrl.options.length=0;
      var oOption;
      for (var i=1;i<=DaysCount;i++){
      oOption = document.createElement('option');
      DayCtrl.options.add(oOption);
      oOption.innerHTML=i;
      oOption.value=i;
      if (i==lastDayValue) oOption.selected=true;
      }
      }

      Regards, Venkatesh Mookkan. Software Engineer

      1 Reply Last reply
      0
      • I indian143

        Post back is the only problem for me I dont want to use it. I want to display a Date field with three combo boxes. When month and year are selected, automatically the days combo must me filled with those many number of days according to leap or not and then 31 or 30 like that. I want to do all this stuff using Javascript function. So please help me if any body could do it. Thank you.

        S/W Engineer Akebono Soft Technologies aleem_abdul@akebonosoft.com.

        M Offline
        M Offline
        m rastgar
        wrote on last edited by
        #3

        var elSel = document.getElementById('selectX'); if (elSel.selectedIndex >= 0) { var elOptNew = document.createElement('option'); elOptNew.text = 'Insert' + num; elOptNew.value = 'insert' + num; var elOptOld = elSel.options[elSel.selectedIndex]; try { elSel.add(elOptNew, elOptOld); // standards compliant; doesn't work in IE } catch(ex) { elSel.add(elOptNew, elSel.selectedIndex); // IE only } Thanks Rastgar

        I 2 Replies Last reply
        0
        • M m rastgar

          var elSel = document.getElementById('selectX'); if (elSel.selectedIndex >= 0) { var elOptNew = document.createElement('option'); elOptNew.text = 'Insert' + num; elOptNew.value = 'insert' + num; var elOptOld = elSel.options[elSel.selectedIndex]; try { elSel.add(elOptNew, elOptOld); // standards compliant; doesn't work in IE } catch(ex) { elSel.add(elOptNew, elSel.selectedIndex); // IE only } Thanks Rastgar

          I Offline
          I Offline
          indian143
          wrote on last edited by
          #4

          I tried to connect in this way the javascript function to "OnSelectedIndexChanged" event hanlder. But Its not giving me any thing. Means its not adding this "Javascript" function to the event. What may be the problem. If you can please help me by giving some code snippet too please. ddlMonRes.Attributes.Add("OnSelectedIndexChanged", "GetDayOfMonth1();")

          S/W Engineer Akebono Soft Technologies aleem_abdul@akebonosoft.com.

          1 Reply Last reply
          0
          • M m rastgar

            var elSel = document.getElementById('selectX'); if (elSel.selectedIndex >= 0) { var elOptNew = document.createElement('option'); elOptNew.text = 'Insert' + num; elOptNew.value = 'insert' + num; var elOptOld = elSel.options[elSel.selectedIndex]; try { elSel.add(elOptNew, elOptOld); // standards compliant; doesn't work in IE } catch(ex) { elSel.add(elOptNew, elSel.selectedIndex); // IE only } Thanks Rastgar

            I Offline
            I Offline
            indian143
            wrote on last edited by
            #5

            I tried to connect in this way the javascript function to "OnSelectedIndexChanged" event hanlder. But Its not giving me any thing. Means its not adding this "Javascript" function to the event. What may be the problem. If you can please help me by giving some code snippet too please. ddlMonRes.Attributes.Add("OnSelectedIndexChanged", "GetDayOfMonth1();")

            S/W Engineer Akebono Soft Technologies aleem_abdul@akebonosoft.com.

            M 1 Reply Last reply
            0
            • I indian143

              I tried to connect in this way the javascript function to "OnSelectedIndexChanged" event hanlder. But Its not giving me any thing. Means its not adding this "Javascript" function to the event. What may be the problem. If you can please help me by giving some code snippet too please. ddlMonRes.Attributes.Add("OnSelectedIndexChanged", "GetDayOfMonth1();")

              S/W Engineer Akebono Soft Technologies aleem_abdul@akebonosoft.com.

              M Offline
              M Offline
              Mircea Grelus
              wrote on last edited by
              #6

              OnSelectedIndexChanged is a serverside event handler. The javascript corespondent in onChange.

              regards, Mircea Many people spend their life going to sleep when they’re not sleepy and waking up while they still are.

              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