SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Free me php klassicd's Avatar
    Join Date
    Sep 2001
    Location
    San Diego
    Posts
    509
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Hotmail type contact List

    I would like to add a function to my site that would work like this:

    A user clicks a link that pops up a new window with 20 or so options with checkbox's next to them. The user can select how many he wants then hits OK button.

    That button closes the window and populates the a form text box in the original window with the id of each check box.

    For example a user who selected 4 items and clicks ok will have a text box with a value much like this:
    1453,2341,1513,1342

    It's alot like hotmails system where you can select contacts and then it will populate the To and CC parts of the message window.

    Only thing is I have no idea where to start to make something like this? Can anyone provide me with some functions I should look into or even perhaps a psuedo code example of what I need to do?

    Thanks

  2. #2
    SitePoint Enthusiast
    Join Date
    Apr 2003
    Location
    Maryland, USA
    Posts
    41
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hopefully this is what you are talking about.

    Save the following as a HTML file.

    Code:
    <HTML>
    <HEAD>
    	<TITLE>Parent Window</TITLE>
    <SCRIPT LANGUAGE="JavaScript">
    function openWindow()
    {
    	window.open( "childWindow.html", "windowName", "" );
    	return false;
    }
    </SCRIPT>
    </HEAD>
    
    <BODY>
    <FORM NAME="parentForm">
    	<INPUT TYPE="text" NAME="parentTextBox">
    	<INPUT TYPE="button" NAME="openChildWindow" VALUE="Open Child Window" ONCLICK="return openWindow();">
    </FORM>
    </BODY>
    </HTML>
    Save the following as "childWindow.html".

    Code:
    <HTML>
    <HEAD>
    	<TITLE>Child Window</TITLE>
    <SCRIPT LANGUAGE="JavaScript">
    function fillParentForm( theForm )
    {
    	checkedCounter = 0;
    	checkedValueArray = new Array;
    
    	for ( i = 0; i < theForm.elements.length; ++i )
    	{
    		// Is this a checkbox?
    		if ( theForm.elements[i].type == 'checkbox' )
    		{
    			// Is this checkbox checked?
    			if( theForm.elements[i].checked )
    			{
    				// Put the checked value in the array.
    				checkedValueArray[checkedCounter] = theForm.elements[i].value;
    				checkedCounter++;
    			}
    		}
    	}
    
    	// Populate the textbox in the parent window.
    	self.opener.document.forms[0].parentTextBox.value = checkedValueArray.join();
    	
    	// Closing child window.
    	window.close();
    }
    </SCRIPT>
    </HEAD>
    
    <BODY>
    <FORM NAME="childForm">
    	<INPUT TYPE="checkbox" NAME="cb123" VALUE="123">123<BR>
    	<INPUT TYPE="checkbox" NAME="cb234" VALUE="234">234<BR>
    	<INPUT TYPE="checkbox" NAME="cb345" VALUE="345">345<BR>
    	<INPUT TYPE="checkbox" NAME="cb456" VALUE="456">456<BR>
    	<INPUT TYPE="checkbox" NAME="cb567" VALUE="567">567<BR>
    	<INPUT TYPE="button" NAME="ok" VALUE="OK" ONCLICK="fillParentForm( childForm );">
    </FORM>
    </BODY>
    </HTML>

  3. #3
    Free me php klassicd's Avatar
    Join Date
    Sep 2001
    Location
    San Diego
    Posts
    509
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Great thank you so much for the help. Works great.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •