Adding a new entry to a list menu based on a database

D

Derek

Let's say I have a dynamic list/menu, which gets its values from a
database table, for example a list of contact people where the value is
an ID number and the label is the name. However, if the value the user
wants is not in the list I would like to place a hyperlink which
will...

(1) open a small window, with an ASP form to allow the user to add a
new entry
(2) save the entry to the database
(3) add that value to the list/menu in the parent window and make it
the selected option
(4) close the small window and return to the original window.

I can handle the code for 1,2 and 4, but 3 is what I'm not sure about.
I don't like the idea of forcing the user to leave the current screen,
go to some other form, add the entry they need to the lookup table,
then come back; this seems like a logical approach, but just wondering
how to make it work.

This seems like a common enough situation; anyone have any code samples
or suggestions about how to do this?

Thanks in advance, and email responses preferred.

Regards,
Derek Gould
Newfoundland, Canada
 
C

Curt_C [MVP]

(3) add that value to the list/menu in the parent window and make it
the selected option

I can handle the code for 1,2 and 4, but 3 is what I'm not sure about.
I don't like the idea of forcing the user to leave the current screen,
go to some other form, add the entry they need to the lookup table,
then come back; this seems like a logical approach, but just wondering
how to make it work.

call the parent window to refresh when the child (modal?) is
closed/returned.
 
D

Derek

I don't want to refresh the parent window, since the user may have
completed half the form and I don't want to reset all values to
default. I just want to update the dropdown by adding the new item to
it, and set it as the currently selected option.
 
C

Curt_C [MVP]

Derek said:
I don't want to refresh the parent window, since the user may have
completed half the form and I don't want to reset all values to
default. I just want to update the dropdown by adding the new item to
it, and set it as the currently selected option.
Ok.. you never mentioned it was a DropDown, you said dynamic list...
guess I interpreted that differently.

Only way you can do this would be to pass the info to clientside
javascript, so the ASP group (where I'm answering you from is probably
not a good place to look.
 
P

Peter Schaefer

Here's a small code sample you can paste to test out. you can pass your
dynamic values to get it to work. put this on the parent page and call
it from your pop-up, but remember to use the "opener" keyword >>
opener.addOption(val,val,val) so it will call the right place.
<html><head>
<script language="javascript" type="text/javascript">
function addOption(combo,text,value)
{
var newOpt=new Option(text,value);
var len=document.getElementById(combo).options.length;
document.getElementById(combo).options[len]=newOpt;
document.getElementById(combo).options[len].selected=true;
}
</script>
</head>
<body >
<form>
<select name="sel" id="sel">
<option value="coke">Coca-Cola</option>
</select>
<input type="button" onclick="addOption('sel','Pepsi-Cola','pepsi')"
value="add" />
</body>
</html>

if you need more info on integrating it, just ask.

TheGeek
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,148
Messages
2,570,838
Members
47,385
Latest member
Joneswilliam01

Latest Threads

Top