473,472 Members | 1,831 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

reload a select list on button click not reloading the whole page

3 New Member
i just want to refresh a select list on button click .Dont want to reload the page.
Jan 7 '13 #1
5 2845
Anas Mosaad
185 New Member
Any introductory AJAX tutorial will tell you how to do that. If you have any issues I can help. What is the problem you are currently facing?
Jan 7 '13 #2
Susmita swasti
3 New Member
Actually I have 2 <select> tag.
i.e.
Expand|Select|Wrap|Line Numbers
  1. <select id="id1"  multiple class="chznselect"  >
  2.   <option value="volvo"  >Volvo</option>
  3.   <option value="saab" >Saab</option>
  4. </select>
  5. <select id="id2"  multiple class="chznselect"  onchange="">
  6.   <option value="opel"  >Opel</option>
  7.   <option value="audi">Audi</option>
  8. </select>
my requirement is dat if I am selecting "volvo" value from 1st drop down box then 2nd drop down box will get refreshed with "audi" value selected by default.i.e. we have to dynamically assign Selected="Selected" for <option value="opel" >Opel</option>..
plz help me ....u can use jQuery or Ajax ..
Jan 7 '13 #3
Anas Mosaad
185 New Member
It seems to me that you don't need to interact with the server. You have everything on your page. You just need the mapping logic in your JS.

Simply, onchange of the first list, check the value and select the equivalent option of the second select list - For example, to select opel using JQuery:
Expand|Select|Wrap|Line Numbers
  1. $("#id1").change(function() {
  2.     $("#id1 option:selected").each(function () {
  3.         alert("volvo" == $(this).val());
  4.            if("volvo" == $(this).val()) 
  5.              $('#id2 option[value="opel"]').attr("selected", true);
  6.        })
  7. });
  8.  
Jan 7 '13 #4
Susmita swasti
3 New Member
oopsss i tried ur code. but its not working...
can u suggest me any other way..

the code u hv provided change the attribute value but the second select list is not gettting refreshed..
Jan 8 '13 #5
Anas Mosaad
185 New Member
What do u actually mean by getting refreshed. You need to deselect all?
This snippet clear all selection:
Expand|Select|Wrap|Line Numbers
  1. $("#id2 option:selected").each(function(){
  2.   $(this).removeAttr("selected");
  3. });
  4.  
Jan 8 '13 #6

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

Similar topics

8
by: Aspersion | last post by:
I'm building an ASP page that has a lot of text and graphics. There is a calculation facility on the page. The user enters several numbers in a form and presses a button to see the calculated...
4
by: bobsawyer | last post by:
I've been building a series of SELECT lists that are populated dynamically using HTTPRequest. Things are going pretty well, and I've got the whole thing working flawlessly in Mozilla/Firebird....
3
by: Damjan Vengu¹t | last post by:
Hey ! I have a WebForm with several controls on it (text boxes, buttons, datagrid, listboxes,...). I want to refresh the data in those controls every 1-2 seconds. How do I refresh (reload)...
5
by: John Bonds | last post by:
I'm having a dumb problem I put a few TextBoxes on a page and a few RequiredFieldValidators and a button. For some reason when I click the button, my browser still makes a round trip (postback)...
0
by: Dan Sikorsky | last post by:
How do you act on a user control's (.ascx) button click event in the containing page (.aspx) ? Should event bubbling be considered? Does this even make sense to try and do? Should the user...
4
by: rn5a | last post by:
A Form has 2 select lists. The 1st one whose size is 5 (meaning 5 options are shown at any given time) allows multiple selection whereas the 2nd one allows only 1 option to be selected at a time. ...
3
by: GauravGupta | last post by:
i want to know that is it posible to call button click event before page load event on post back.... please help me....
2
by: GauravGupta | last post by:
i am displaying a table in page load whose data is fetched from database . it also check what data is to be displayed from data base by a session variable. and i have few button which change the...
1
by: Hooyoo | last post by:
Hi, everyone. I want "steal" data from a web page :), but their data are stored in a data grid, and more than 1,000 pages in the data grid. Everytime I need click "Next Page" to view next page...
4
by: mohaaron | last post by:
This seems like it should be simple to do but for some reason I have been unable to make it work. I would like to databind a SqlDataSource to a GridView during the click event of a button. This...
0
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,...
0
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...
0
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...
0
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,...
0
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.