473,830 Members | 2,174 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ListItems added using Js gets cleared on Page load?

94 New Member
Hi ALL,
I am binding ListItems to dropdownlist using js.But the selected value is not retained while save operation. Do I need to capture the selected Item in any hiddenfields ?
plz tell me

Sudha
Oct 10 '07 #1
25 2131
dmjpro
2,476 Top Contributor
Hi ALL,
I am binding ListItems to dropdownlist using js.But the selected value is not retained while save operation. Do I need to capture the selected Item in any hiddenfields ?
plz tell me

Sudha
Your save operation gets processed properly or it stops to do that?
Let me know.
I think when you submit the page then according to browser settings this happnes.
I think it should not harm your page submitting.

Debasis Jana
Oct 10 '07 #2
sudhaMurugesan
94 New Member
Your save operation gets processed properly or it stops to do that?
Let me know.
I think when you submit the page then according to browser settings this happnes.
I think it should not harm your page submitting.

Debasis Jana
This is my Code. I dont know why this is happening its due to Ajax or due to any wrong with my code
Expand|Select|Wrap|Line Numbers
  1. function Major()
  2. {
  3. var deg = document.getElementById ("ctl00_ContentPlaceHolder1_ddlDegree");
  4.  
  5.  if(deg.selectedIndex != 0)
  6.     {
  7.     AjaxWebService.GetMajor(deg.options[deg.selectedIndex].value,OnGetMajor);       
  8.     }
  9.  
  10. }
  11. function OnGetMajor(Items)
  12. {
  13.  
  14. var major = document.getElementById ("ctl00_ContentPlaceHolder1_ddlMajor");
  15. if(major.options.length > 0)
  16. {
  17. major.options.length = 0;// to remove previously binded items
  18. }
  19. var o = document.createElement("option");
  20. o.text = "----Select----";
  21. o.value = 0;
  22. major.add(o);
  23. for(i=0;i<Items.length;i++)
  24. {
  25. var options = Items[i].split(",");
  26. var o = document.createElement("option");
  27. o.text = options[1];
  28. o.value = options[0];
  29. major.add(o);
  30. }
  31. }
Can you find out?
Oct 10 '07 #3
sudhaMurugesan
94 New Member
Your save operation gets processed properly or it stops to do that?
Let me know.
I think when you submit the page then according to browser settings this happnes.
I think it should not harm your page submitting.

Debasis Jana
I have kept these fields mandatory and only if these listitems are not null it will get saved. But the listitems are getting cleared during page load.
Oct 10 '07 #4
dmjpro
2,476 Top Contributor
This is my Code. I dont know why this is happening its due to Ajax or due to any wrong with my code
Expand|Select|Wrap|Line Numbers
  1. function Major()
  2. {
  3. var deg = document.getElementById ("ctl00_ContentPlaceHolder1_ddlDegree");
  4.  
  5.  if(deg.selectedIndex != 0)
  6.     {
  7.     AjaxWebService.GetMajor(deg.options[deg.selectedIndex].value,OnGetMajor);       
  8.     }
  9.  
  10. }
  11. function OnGetMajor(Items)
  12. {
  13.  
  14. var major = document.getElementById ("ctl00_ContentPlaceHolder1_ddlMajor");
  15. if(major.options.length > 0)
  16. {
  17. major.options.length = 0;// to remove previously binded items
  18. }
  19. var o = document.createElement("option");
  20. o.text = "----Select----";
  21. o.value = 0;
  22. major.add(o);
  23. for(i=0;i<Items.length;i++)
  24. {
  25. var options = Items[i].split(",");
  26. var o = document.createElement("option");
  27. o.text = options[1];
  28. o.value = options[0];
  29. major.add(o);
  30. }
  31. }
Can you find out?
At which point your Ajax Call made and where your "Select Box" gets cleared?
Let me know ... Quick!

Debasis Jana
Oct 10 '07 #5
dmjpro
2,476 Top Contributor
I have kept these fields mandatory and only if these listitems are not null it will get saved. But the listitems are getting cleared during page load.
What do you mean by "Page Load"?
What is your sever side Script?

Debasis Jana
Oct 10 '07 #6
sudhaMurugesan
94 New Member
At which point your Ajax Call made and where your "Select Box" gets cleared?
Let me know ... Quick!

Debasis Jana
onchange event of degree, i have called the js.In that code only i'm calling ajax;
But i trying to find where actually listitems is getting cleared
Oct 10 '07 #7
dmjpro
2,476 Top Contributor
onchange event of degree, i have called the js.In that code only i'm calling ajax;
But i trying to find where actually listitems is getting cleared
If you are using J2EE container ...... then you can post your whole code.
Means the the "Server Side Script" and the JavaScript File.
So that I can do test.
Or you can send me your generated HTML file.
Your Client Side Script is HTML or something else?

Debasis Jana
Oct 10 '07 #8
sudhaMurugesan
94 New Member
If you are using J2EE container ...... then you can post your whole code.
Means the the "Server Side Script" and the JavaScript File.
So that I can do test.
Or you can send me your generated HTML file.
Your Client Side Script is HTML or something else?

Debasis Jana
Its ASP.net. I am doubting In this part of the code.

Expand|Select|Wrap|Line Numbers
  1. function Major()
  2. {
  3. var deg = document.getElementById ("ctl00_ContentPlaceHolder1_ddlDegree");
  4.  
  5.  if(deg.selectedIndex != 0)
  6.     {
  7.     AjaxWebService.GetMajor(deg.options[deg.selectedIndex].value,OnGetMajor);       
  8.     }
  9.  
  10. }
  11. function OnGetMajor(Items)
  12. {
  13.  
  14. var major = document.getElementById ("ctl00_ContentPlaceHolder1_ddlMajor");
  15. if(major.options.length > 0)
  16. {
  17. major.options.length = 0;// to remove previously binded items
  18. }
  19. var o = document.createElement("option");
  20. o.text = "----Select----";
  21. o.value = 0;
  22. major.add(o);
  23. for(i=0;i<Items.length;i++)
  24. {
  25. var options = Items[i].split(",");
  26. var o = document.createElement("option");
  27. o.text = options[1];
  28. o.value = options[0];
  29. major.add(o);
  30. }
  31. }
Oct 10 '07 #9
dmjpro
2,476 Top Contributor
Its ASP.net. I am doubting In this part of the code.

Expand|Select|Wrap|Line Numbers
  1. function Major()
  2. {
  3. var deg = document.getElementById ("ctl00_ContentPlaceHolder1_ddlDegree");
  4.  
  5.  if(deg.selectedIndex != 0)
  6.     {
  7.     AjaxWebService.GetMajor(deg.options[deg.selectedIndex].value,OnGetMajor);       
  8.     }
  9.  
  10. }
  11. function OnGetMajor(Items)
  12. {
  13.  
  14. var major = document.getElementById ("ctl00_ContentPlaceHolder1_ddlMajor");
  15. if(major.options.length > 0)
  16. {
  17. major.options.length = 0;// to remove previously binded items
  18. }
  19. var o = document.createElement("option");
  20. o.text = "----Select----";
  21. o.value = 0;
  22. major.add(o);
  23. for(i=0;i<Items.length;i++)
  24. {
  25. var options = Items[i].split(",");
  26. var o = document.createElement("option");
  27. o.text = options[1];
  28. o.value = options[0];
  29. major.add(o);
  30. }
  31. }
Ok let me understand your code.
You have two "Select Box"s ..... "onchange" event of "degree" the major gets cleared and refilled with new one, what you get from Server Side.
This is what happening.
Up to this I am right ?
Now tell me what is being cleared?
Here I am not getting your Point.

Debasis Jana.
Oct 10 '07 #10

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

Similar topics

16
15756
by: Dave Smithz | last post by:
Hi, In summary: I want to a form to submit information via a HTTP POST, however, when using Internet Explorer I want to be able to use the back button and all the information retained. Presently we get a "Page has expired" message. How can we avoid this? Full details: Having searched for postings on how to avoid the "Page has Expired" they are
1
1642
by: john | last post by:
I have two different problems: 1. When the user has clicked on a button that is causing the browser to post back to the server, it could take a little while for the new page to show up. So in the mean time, I want to change the cursor to an hourglass and disable all of the controls on the form using javascript so the user can't do anything with any of the controls on the page. But when I disable certain controls (e.g. text boxes, radio...
2
5009
by: Sam | last post by:
I have a custom control (MyTextBox - taken from Microsoft website) that implements the IPostBackDataHandler interface. It is added to the controls collection of a placeholder control during the Page Load of a main ASPX page. Now if we debug the MyTextBox, we find the order of events like so (during a Posback, of course): OnInit -> OnLoad -> LoadPostData. My question is why does the LoadPostData occur *after* the OnLoad instead of...
2
2228
by: raffe | last post by:
Hi all! I have a control which represents a user record in my database and a save button. It get's loaded into a placeholder and all the controls like TextBox get bound to the data source. At the same time I put record id in the ViewState collection. When the save button click event gets fired the ViewState collection is empty. How can that happen? All the TextBoxes on the control still have their values. I have read that all controls...
9
2456
by: Anders K. Jacobsen [DK] | last post by:
Hi I have this that adds some usercontrol (UCTodays.ascx) to a placeholder foreach(A a in B){ UCTodays ucline = (UCTodays )LoadControl("UCTodays.ascx"); ucline.Initializecontrol(line,alternate); Placeholder1.Controls.Add(ucline); }
3
2092
by: Joe | last post by:
Hello All, I am populating an HtmlSelect control's Items property with four list items. The HtmlSelect control is contained in a user control which is dropped into a placeholder on the web form. When the page is rendered, the control is empty. Here is the code: In the web form: Dim UControl As AugmentedDropDownList =
2
1815
by: Arthur Dent | last post by:
Hi all, I have a control which i wrote which inherits the asp:dropdownlist control. Works great, all happy. If when using it i try to declaratively add some items, it complains that they are unknown types. eg... <mytag:mydropdownlist id="lstInherited" runat="server" appenddatabounditems="true" > <asp:listitem id="" value="select an item" >
7
2154
by: Nathan Sokalski | last post by:
I have a page which I dynamically add several usercontrols (*.ascx files) to using the following code: Public Sub Refresh() For Each section As DataRow In Me.GetSections().Rows CType(Me.FindControl("admin" & CStr(section("buttontext")).Replace(" ", "")), adminsection2).RefreshSection() Next End Sub
8
7788
by: sudhaMurugesan | last post by:
Hi, Can anyone Help. I have two dropdownlist for qualification and degree. According to the qualification(eg.Diploma,UG,PG) degree gets binded in the dropdownlist. I have done this in javascript.It works fine but the values binded early does not get cleared. How to remove previously binded items and rebind with new Items.If any corrections i Have to do then please tell me.Urgent. I await for reply. My code is // Items is an array like ...
0
9791
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
9642
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10487
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...
1
10525
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9313
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
7745
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
5617
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3958
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3076
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.