ListItems added using Js gets cleared on Page load?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sudhaMurugesan
    New Member
    • May 2007
    • 94

    #16
    Originally posted by dmjpro
    What do you mean by this "During PageLoad this degree is null"?
    Please Clarify me here.
    And post your "PageLoad" function.
    Let me have a look here.

    Debasis Jana
    I myself confused a lot. I dont know what was happening. I give you my whole code sir. you please check where i am wrong.But please give me some time to explain u what i'm really doing. Is it Time up for you now and I too have got only 15 mins.

    Comment

    • dmjpro
      Top Contributor
      • Jan 2007
      • 2476

      #17
      Originally posted by sudhaMurugesan
      I myself confused a lot. I dont know what was happening. I give you my whole code sir. you please check where i am wrong.But please give me some time to explain u what i'm really doing. Is it Time up for you now and I too have got only 15 mins.
      Right now I am getting confused.
      Can't you make me clear?
      Actually why "degree" Select Box is null initially?
      And you populate the "major" Select Box when you change first one, right?
      oh.....I am now getting confused.
      Tell me actual scenario and paste the Generated HTML and whole JavaScript.
      So that I can have a look at this and make me understand myself.

      Debasis Jana

      Comment

      • sudhaMurugesan
        New Member
        • May 2007
        • 94

        #18
        Originally posted by dmjpro
        Right now I am getting confused.
        Can't you make me clear?
        Actually why "degree" Select Box is null initially?
        And you populate the "major" Select Box when you change first one, right?
        oh.....I am now getting confused.
        Tell me actual scenario and paste the Generated HTML and whole JavaScript.
        So that I can have a look at this and make me understand myself.

        Debasis Jana
        Now I will tell u clearly ok.
        Degrees[B.A/B.E] Majors for B.A[English,History] for B.E[ECE,EEE,IT]
        Now if i Select B.A in degree select box, the Majors for B.A gets binded in Major selectbox dynamically using javascript. Now If i select English as Major and click Save button, the Value English is not carried to Server side[C#.net] where i save the value to database . Some of my colleagues saying me to capture the value in hidden fields and then pass to server side. I know that this is not effective.In generated Html also the major's selected value is 0 having text "--Select--". I will Paste the Generated HTML code also. I value ur suggestion more.

        Thank U.

        Comment

        • sudhaMurugesan
          New Member
          • May 2007
          • 94

          #19
          Originally posted by dmjpro
          Right now I am getting confused.
          Can't you make me clear?
          Actually why "degree" Select Box is null initially?
          And you populate the "major" Select Box when you change first one, right?
          oh.....I am now getting confused.
          Tell me actual scenario and paste the Generated HTML and whole JavaScript.
          So that I can have a look at this and make me understand myself.

          Debasis Jana
          My Generated HTML Code
          Code:
           <tr>
                  <td>
                      <span id="ctl00_ContentPlaceHolder1_Label66">Qualification Level</span></td>
                  <td>
                      <select name="ctl00$ContentPlaceHolder1$ddlQualification" id="ctl00_ContentPlaceHolder1_ddlQualification" onchange="HideQualification();getQualification();" style="width:71%;">
          	<option selected="selected" value="0">---Select---</option>
          	<option value="38">SSLC</option>
          	<option value="39">HSC</option>
          	<option value="40">ITI</option>
          	<option value="41">DIPLOMA</option>
          	<option value="42">NON-ENGG GRADUATE</option>
          	<option value="44">ENGG GRADUATE</option>
          
          </select>
                      <span id="ctl00_ContentPlaceHolder1_Label28" class="ErrorText">*</span></td>
                  <td >
                      <div id="ctl00_ContentPlaceHolder1_DivlblInstitute"><span id="ctl00_ContentPlaceHolder1_lblInstitute">Institute :</span>&nbsp;</div> </td>
                  <td >
                     <div id="ctl00_ContentPlaceHolder1_DivtxtInstitute"> <input name="ctl00$ContentPlaceHolder1$txtInstitute" type="text" id="ctl00_ContentPlaceHolder1_txtInstitute" onkeypress="FilterChracterInputs();" style="width:160px;" />
                         <span id="ctl00_ContentPlaceHolder1_Label9" class="ErrorText">*</span></div> </td>
              </tr>
               <tr id="ctl00_ContentPlaceHolder1_trdegree">
          	<td>
                      <span id="ctl00_ContentPlaceHolder1_lblDegree">Degree</span></td>
          	<td><select name="ctl00$ContentPlaceHolder1$ddlDegree" id="ctl00_ContentPlaceHolder1_ddlDegree" onchange="Major();" style="width:71%;">
          		<option selected="selected" value="0">----Select----</option>
          
          	</select>
                      <span id="ctl00_ContentPlaceHolder1_Label19" class="ErrorText">*</span></td>
          	<td>
                      <span id="ctl00_ContentPlaceHolder1_lblMajor">Major</span></td>
          	<td>            <select name="ctl00$ContentPlaceHolder1$ddlMajor" id="ctl00_ContentPlaceHolder1_ddlMajor" style="width:87%;">
          		<option value="0">----Select----</option>
          
          	</select>
                      <span id="ctl00_ContentPlaceHolder1_Label16" class="ErrorText">*</span></td>
          </tr>
          //javascript
          function getQualification()
          {
              var e = document.getElementById ("ctl00_ContentPlaceHolder1_ddlQualification");
           var qualification = e.options[e.selectedIndex].text;[B] // eg. ENGG GRADUATE[/B]
              if(e.selectedIndex != 0)
              {
              AjaxWebService.GetDegree(qualification,OnGetDegree);   //Returns Items[n]
              }
          }
          function OnGetDegree(Items)
          { 
          [B]//Items[0] = "44,B.E/B.Tech"[/B]
          var degri = document.getElementById ("ctl00_ContentPlaceHolder1_ddlDegree");
          var length = degri.options.length;
          if(degri.options.length > 0)
          {
          degri.options.length = 0;
          //    var count=0;
          //    for ( ; count < e.options.length ;)
          //    {  
          //    e.remove(count);
          //    count = 0;
          //    }
          }
          var o = document.createElement("option");
          o.text = "----Select----";
          o.value = 0;
          degri.add(o);
          for(i=0;i<Items.length;i++)
          {
          var options = Items[i].split(",");
          var o = document.createElement("option");
          o.text = options[1]; // "B.E/B.Tech"
          o.value = options[0]; // "44 "
          degri.add(o);
          }
          
          }
          function Major()
          {
          var deg = document.getElementById ("ctl00_ContentPlaceHolder1_ddlDegree");
          
           if(deg.selectedIndex != 0)
              {
              AjaxWebService.GetMajor(deg.options[deg.selectedIndex].value,OnGetMajor);       
              }
              
          }
          function OnGetMajor(Items)
          {
          [B]//Items[0] = "2,ECE"  Items[1] = "3,EEE"[/B]
          var major = document.getElementById ("ctl00_ContentPlaceHolder1_ddlMajor");
          if(major.options.length > 0)
          {
          major.options.length = 0;// to remove previously binded items
          }
          var o = document.createElement("option");
          o.text = "----Select----";
          o.value = 0;
          major.add(o);
          for(i=0;i<Items.length;i++)
          {
          var options = Items[i].split(",");
          var o = document.createElement("option");
          o.text = options[1];
          o.value = options[0];
          major.add(o);
          }
          }

          Comment

          • dmjpro
            Top Contributor
            • Jan 2007
            • 2476

            #20
            Now tell me Sudha.......... ...
            You don't want to get the Degree List blank initially?
            Then you can send me your Server Side Script.
            As .Net & J2eeis almost same.
            So I can have a look at this.
            Don't you have any "<body onload="some_fu nc()">"?
            Please let me all these things and send me the Server Side Script.

            Debasis Jana.

            Comment

            • sudhaMurugesan
              New Member
              • May 2007
              • 94

              #21
              Originally posted by dmjpro
              Now tell me Sudha.......... ...
              You don't want to get the Degree List blank initially?
              Then you can send me your Server Side Script.
              As .Net & J2eeis almost same.
              So I can have a look at this.
              Don't you have any "<body onload="some_fu nc()">"?
              Please let me all these things and send me the Server Side Script.

              Debasis Jana.
              How to send it is 950 lines. I tried thro' gmail but failed

              Code:
              <script type="text/javascript" language="javascript">
              //These js Functions gets called on load
                HideESI()
                HideOldBank()
                HideforDL()
                HideQualification()
                HideExperience()
                Major()
                 </script>

              Comment

              • dmjpro
                Top Contributor
                • Jan 2007
                • 2476

                #22
                Originally posted by sudhaMurugesan
                How to send it is 950 lines. I tried thro' gmail but failed

                Code:
                <script type="text/javascript" language="javascript">
                //These js Functions gets called on load
                  HideESI()
                  HideOldBank()
                  HideforDL()
                  HideQualification()
                  HideExperience()
                  Major()
                   </script>
                There you can't figure Out.?

                Debasis Jana

                Comment

                • sudhaMurugesan
                  New Member
                  • May 2007
                  • 94

                  #23
                  Originally posted by dmjpro
                  There you can't figure Out.?

                  Debasis Jana
                  Its getting delayed. I try with hidden fields atlast.I knowyou tried to help me a lot.But sorry i am unable to provide you with proper Inputs.sorry frnd.

                  Comment

                  • dmjpro
                    Top Contributor
                    • Jan 2007
                    • 2476

                    #24
                    Originally posted by sudhaMurugesan
                    Its getting delayed. I try with hidden fields atlast.I knowyou tried to help me a lot.But sorry i am unable to provide you with proper Inputs.sorry frnd.
                    Best of Luck with that.

                    Debasis Jana

                    Comment

                    • sudhaMurugesan
                      New Member
                      • May 2007
                      • 94

                      #25
                      Originally posted by dmjpro
                      Best of Luck with that.

                      Debasis Jana
                      hello Jana,
                      My tries all failed.Hidden field is also failed becoz' on Bodyload call to AjaxWebservice fails . so My select box filled with no options. only this options value i am storing in hidfield which thro's error : option is null. So I finally decided to do it on Server Side. I am very bad in understanding the control flow which swallowed all my time. OK Jana check your PM.

                      Comment

                      • dmjpro
                        Top Contributor
                        • Jan 2007
                        • 2476

                        #26
                        Originally posted by sudhaMurugesan
                        hello Jana,
                        My tries all failed.Hidden field is also failed becoz' on Bodyload call to AjaxWebservice fails . so My select box filled with no options. only this options value i am storing in hidfield which thro's error : option is null. So I finally decided to do it on Server Side. I am very bad in understanding the control flow which swallowed all my time. OK Jana check your PM.
                        So your Problem is with Ajax Call.

                        Debasis Jana

                        Comment

                        Working...