473,394 Members | 1,866 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

quicky... form & pop up...

Mel
i have an text field and a button

when user click on button it popups up list of emails in a form

user selects a bunch of people from the form (check boxes) and when the
window is closed the selection should be placed in the text field separated
by ";" semicolon

can someone help ?
Jul 23 '05 #1
3 1238
VK
> can someone help ?

Yeh... You need to use JavaScript!
Jul 23 '05 #2
Lee
Mel said:

i have an text field and a button

when user click on button it popups up list of emails in a form

user selects a bunch of people from the form (check boxes) and when the
window is closed the selection should be placed in the text field separated
by ";" semicolon

can someone help ?


<html>
<head>
<title>demo</title>
<script type="text/javascript">
var addressBook=[ "Me", "You", "Him", "Her", "Them" ];
function popup() {
globalHTML="<html><body><form>";
for(var i=0;i<addressBook.length;i++) {
globalHTML+="<input type=\"checkbox\" name=\"c\" value=\""
+addressBook[i]+"\">&nbsp;"+addressBook[i]+"<br>\n";
}
globalHTML+="<center><input type=\"button\" value=\"Done\" onclick=\""
+"opener.importAddr(this.form);self.close()\"></center>"
+"</form></body></html>";
window.open("javascript:opener.globalHTML",
"popup","width=400,height=400,resizable");
}
function importAddr(f) {
for(var i=0;i<f.c.length;i++) {
if(f.c[i].checked) {
document.forms[0].toAddr.value+=f.c[i].value+";";
}
}
}
</script>
</head>
<body>
<form>
<input type="button" value="To:" onclick="popup()">
<input name="toAddr">
</form>
</body>
</html>

Jul 23 '05 #3
Lee wrote:
Mel said:

[...]
can someone help ?


Lee's solution is OK, here's an improvement (to me anyway). The
addresses are only added if there aren't already in the text box.

The HTML is constructed as an array, then written to the window which
may be faster as the list of addresses gets longer.

Creates the window as a local variable.

Gets rid of "javascript" in:

window.open("javascript:opener.globalHTML",

Script only, HTML unchanged ... have fun!
<script type="text/javascript">

var addressBook=[ "Me", "You", "Him", "Her", "Them" ];

function popup() {
var newWin = window.open('','popup','width=400,height=400,resiz able');
var globalHTML = ['<html><body><form>'];
for (var i=0; i<addressBook.length; i++) {
globalHTML.push(
'<input type="checkbox" name="c" value="'
+ addressBook[i]
+ '">&nbsp;'
+ addressBook[i]
+ '<br>'
);
}
globalHTML.push(
'<center><input type="button" value="Done"'
+ 'onclick="opener.importAddr(this.form);'
+ 'self.close()"></center>'
+ '</form></body></html>'
);

newWin.document.write(globalHTML.join(''));
newWin.document.close();
}
function importAddr(f) {
var ele = document.forms[0].toAddr;
var addStr = ele.value;
for(var i=0; i<f.c.length; i++) {
if(f.c[i].checked && addStr.indexOf(f.c[i].value) < 0) {
ele.value += f.c[i].value + ";";
}
}
}
</script>
--
Rob
Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Nomen Nescio | last post by:
can anyone be so kind as to look at http://www.mysolution.ws/HYPOCRITE.php and let me know why it isn't passing the form data to http://www.mysolution.ws/insertHYPOCRITES.php for the most...
2
by: iwasinnihon | last post by:
I don't usually like to do this, but I need help. I have gone over this code and cannot figure out why it doesn't work. First of all it doesn't check to see if you have filled in the required...
4
by: ry66 | last post by:
Hello All! Is it possible to submit a form using hyperlink? I want to send hidden element when a link is clicked. I read some books, but I found only using button which I don't want to use. ...
3
by: asianboi | last post by:
Hi, In my application, I have a web browser control and load up a local html page. Within the html page, the following code exists. However, when I click on the button that invokes the 'form...
7
by: eric.goforth | last post by:
Hello, I'm working with a classic asp page that calls another classic asp page. The html in my calling page looks like: <form method="post"...
25
by: Wim Cossement | last post by:
Hello, I was wondering if there are a few good pages and/or examples on how to process form data correctly for putting it in a MySQL DB. Since I'm not used to using PHP a lot, I already found...
2
by: Cerebral Believer | last post by:
Hi folks, Can anyone help me with this form: http://futurebydesign-music.com/_member/club_fbd_reg.php I have followed to coding instructions aas closely as I can, but I am getting errors...
5
anukagni
by: anukagni | last post by:
Dear Friends, I want to display some photo which is relate to the database in a form .. as i am having an ms db form in that i am having three button to open forms what i want to do is when...
5
by: programmerboy | last post by:
I never had this kind of issue before and it is completely surprising. I have a usercontrol where I need 2 forms to make 1 form. When I have only 1 form it submits the page to itself. I have spent...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
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...

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.