strohtm
Posts: 13
|
Posted: 01/25/2005, 8:07 AM |
|
I have the situations where I am filling in a form, then I get to a list box and of course the value I need isn't there.
I would like a popup form that allows me to enter a new value then refreshes or populates the list box on the original form.
This link show exactly what I'm triing to recreate. http://www.gotocode.com/art.asp?art_id=146&
I have triied this example and several variations of it found on this forum.
It seems the problems I'm having are the same issues eveyone else has had.
I have triied the CodeCharge PopUpList in the example pack and do not seem to follow the logic.
The link to the popup window works like a normal link opening the page in the same window. When I click on the link in the should be popup window it takes me to a directory listing.
I have been working on this for a day and a half and still come up with nothing.
Is there a better or up to date example?
Does anyone have any ideas where I might have gone wrong?
I don't even mind if there is a hidden "add a new record" grid on the same page that is visible when the user it. Of course the list box would have to get refreshed and the grid would have to hide after a new record was inserted.
|
|
|
peterr
Posts: 5971
|
Posted: 01/25/2005, 12:24 PM |
|
I just looked at that example at http://examples.codecharge.com/ExamplePack/PopUpList/PopUpList.php and for me it works as intended: selecting a name in the pop-up window places that name into the parent page.
However, this example wasn't meant to populate listboxes and therefore probably isn't what you're looking for.
The question is: do you want to repopulate just the listbox values, or refresh the whole page. Refreshing the page is very simple to do but will result in the loss of data that a user might've already entered, while repopulating just the listbox can be more difficult (I think) and requires JavaScript programming. In the 2nd method you probably would even need to create your own litsbox using JavaScript. I don't know how to do that, but if you respond that this is the method you've selected then possibly someone would help. You could also try this search: http://www.google.com/search?hl=en&lr=&q=javascript+populate+listbox
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
|
|
strohtm
Posts: 13
|
Posted: 01/25/2005, 12:52 PM |
|
I realy need to repopulate the listbox. (list box comes from an table using id fields.)
I would not like to loose the data on the form. If we could live with that I would tell the user to use the existing menu choices.
I would rather it work like example http://www.gotocode.com/art.asp?art_id=146&.
All of the archive forum topics seem to get close put all lead to some sort of dead end.
|
|
|
Nicole
Posts: 586
|
Posted: 01/26/2005, 2:22 AM |
|
Hello,
If you want exactly the example from GotoCode site you can reproduce it on a CCS page I think. It is not too complex. You need to create 3 pages in CCS, JavaScript code is the same (just keep in mind to use real form, field names). Of course ASP code need to be adapted for CCS. I tried to do it. After Insert event of a Record form from a pop up window:
Dim last_value, last_pk
last_pk = CCDLookUp("max(category_id)", "categories", "", DBconnection_name)
last_value = CCDLookUp("name", "categories", "category_id=" & DBconnection_name.ToSQL(last_pk, ccsInteger), DBconnection_name)
Redirect = Redirect & "?last_pk=" & last & "&last_value=" & last_value
Hope it helps.
_________________
Regards,
Nicole |
|
|
strohtm
Posts: 13
|
Posted: 01/26/2005, 5:16 AM |
|
Thanks Nicole, It's now working.
Here's what I ended up with.
My forms table and fields represent software titles.
Bold text is what what is specific to my app.
Link HTML in main page with the list box.
------------------------------------------------------------------------
<a href=javascript:new_category()> Click here to insert a new category<a>
<script language="JavaScript">
function new_category() {
var w = open ('', 'windowName', 'width=500,height=650,titlebar=0');
w.document.open();
w.location.href="popuptitle.asp";
}
</script>
The popup window needs the following Java at the bottom of the page.
-------------------------------------------------------------------------------------------
<script language="JavaScript">
function parseQueryString (str) {
str = str ? str : location.search;
var query = str.charAt(0) == '?' ? str.substring(1) : str;
var args = new Object();
if (query) {
var fields = query.split('&');
for (var f = 0; f < fields.length; f++) {
var field = fields[f].split('=');
args[unescape(field[0].replace(/\+/g, ' '))] =
unescape(field[1].replace(/\+/g, ' '));
}
}
return args;
}
var params = parseQueryString ( window.location.search );
//check if category record is already inserted to out it into other window and close the popup
if ( isFinite( params['last_pk'] ) ) {
var oOption = window.opener.document.createElement("OPTION");
window.opener.document.forms['SoftwareLicenses'].elements['TitleID'].options.add(oOption);
oOption.text = params['last_value'];
oOption.value = params['last_pk'] ;
//alert(window.opener.document.forms['SoftwareLicenses'].elements['TitleID'].options[window.opener.document.forms['SoftwareLicenses'].elements['TitleID'].options.length-1].value);
window.close();
}
</script>
Nicole's code goes in the after update event of the form in the popup window.
---------------------------------------------------------------------------
Dim last_value, last_pk
last_pk = CCDLookUp("max(TitleID)", "SoftwareTitles", "", DBconnection1)
last_value = CCDLookUp("title", "softwaretitles", "titleid=" & DBconnection1.ToSQL(last_pk, ccsInteger), DBconnection1)
Redirect = Redirect & "?last_pk=" & last_pk & "&last_value=" & last_value
The return page property of the add form must be blank.
The preserve parameters porperty of the add form must be set to None.
Thanks!
|
|
|
|