navcan
Posts: 61
|
| Posted: 07/13/2006, 1:10 PM |
|
Does anybody has an ASP example of dependent dropdown list using IFRAMES instead of using onChange which refreshes the whole page causing other other filled fields to go blank.
Thanks.
|
 |
 |
marcwolf
Posts: 361
|
| Posted: 07/13/2006, 6:04 PM |
|
Hi there NavCan
Ok - just to clarify..
You have one list box and when it changes you want another listbox to cange its contents in response to the change.
i.e. Country listbox - when you change an entry in that - the State listbox automatically loads the States for that..
Let me know if that is the case because we use the technique all of the time with IFrames (although we are moving over to AJAX)
Take Care
Dave
_________________
' Coding Coding Coding
Keep Those Keyboards Coding.
Raw Code!!!!!!!
|
 |
 |
navcan
Posts: 61
|
| Posted: 07/14/2006, 5:17 AM |
|
Hi Dave,
Hope all is well, Yes, exactly that was my question if we select a country from dropdown list Country, the next dropdown list name cities should show cities belonging to the Country selected above without refreshing the page. I used the example from CCS examples but onchange event refreshes the whole page resulting all the data entered in other fields to go blank. Please advise if you have a better solution. My whole project is stuck because of this.
Ajax is the best solution but for the time being I need a quick fix.
Thanks and appreciate it.
|
 |
 |
marcwolf
Posts: 361
|
| Posted: 07/15/2006, 4:43 AM |
|
Hi NavCan
Ok - this is a fairly complex subject. I'll incluse some links for you to look at that I used as the basis of my development.
http://www.atgconsulting.com/gofetch.asp http://developer.apple.com/internet/webcontent/iframe.html
But.. Here is the gist of what happens.
Firstly - an IFrame is just a frame that is floating on a standard browser. It also follows all of the frame rules.
Such as any function/control/element on the parent page can be reference using window.parent
Now - within our HTML can make the iframe load a specific ASP page.
And the ASP page can write Javascript in the IFrame to reference the parent page.
Ok - the the basics.. So what does happen (don;t worry - I'll include sample code in a minute)
We have a listbox with an ID of LstCountry. We use the ID more because can can reference it with an getElementById javascript function.
We also have another listbox with an ID of LstState
LstCountry has an OnChange event that calls a function GetStates and passes the currently selected value of LstCountry, and the ID of LstState
Lets use USA as the country
GetState create a string "GetState.ASP?Cntrl=LstState&Country=USA"
and then set the URL of the IFrame to this.
GetState.ASP it\s excuted by the server (just like a normal request from the browser) and gets a recordset of all of the States in the USA.
Then it returns a block of Javascript back to the IFrame that does the following.
1. Remove all existing entries in the LstStates listbox
2. Inserts the new States into the LstStates listbox
And to the user - the LstStates listbox suddenly updates to show the new states without doing a refresh of the whole page.
Now - It will take me a day to get together the examples
Take Care
Dave
_________________
' Coding Coding Coding
Keep Those Keyboards Coding.
Raw Code!!!!!!!
|
 |
 |
navcan
Posts: 61
|
| Posted: 07/17/2006, 7:06 AM |
|
Hey Dave,
Thanks for the brief explanation. Any idea as when you will be able to create an example in CCS. I am sure it will benefit all CCS users.
Appreciate your knowledge and sharing of information.
Regards,
navcan
|
 |
 |