SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: popup

  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2003
    Location
    Pakistan
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    popup

    hi
    i m a new developer and working in php and javascript...what i want to do is on the button click of a PHP page(selectcustomer.php) i want a popup screen that will contain customer names pickedup from the database...now when i will click on a customer from that popup screen. the selected customer will be now coppied in the text box of "selectcustomer.php"
    so kindly tell me how can i do this and if someone can provide me with code.
    mind onething that i m not much experiences
    regards

  2. #2
    SitePoint Enthusiast RaS!'s Avatar
    Join Date
    Mar 2004
    Location
    Italy
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Easy to do...

    Quote Originally Posted by salmanucit
    hi
    i m a new developer and working in php and javascript...what i want to do is on the button click of a PHP page(selectcustomer.php) i want a popup screen that will contain customer names pickedup from the database...now when i will click on a customer from that popup screen. the selected customer will be now coppied in the text box of "selectcustomer.php"
    so kindly tell me how can i do this and if someone can provide me with code.
    mind onething that i m not much experiences
    regards
    It's easy to do. Suppose to have a simply form in the 1st page that contain a text element. Es:

    1st PAGE
    ---------
    HTML Code:
    <form name="f1">
    <input type="text" name="email">
    </form>
    In the second page (popup), simply load a js function like this:
    Code:
    function getData() {
     this.myEmail=opener.document.f1.email.value;
    }
    In the body of 2nd page, just put this:
    Code:
    <script language="Javascript">istance=new getData(); document.write(istance.myEmail);</script>

  3. #3
    SitePoint Wizard silver trophy
    Join Date
    May 2003
    Posts
    1,843
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    
    <html>
    <head>
    <title>selectcustomer.php</title>
    <script type="text/javascript" language="javascript">
    
    var Fwin = null;
    var w = 200;
    var h = 160;
    var l = 260;
    var t = 260;
    
    function openFormWin(url)
    {
    	Fwin = open(url,'Fwin','width='+w+',height='+h+',left='+l+',top='+t+',status=0');
    	if (Fwin && !Fwin.closed)
    		Fwin.focus();
    	return false;
    }
    
    </script>
    </head>
    <body style="background:buttonface;margin:100px;" onload="document.mainform.reset()">
    <form name="mainform">
    <input type="button" value="select customer" 
    onclick="return openFormWin('formpop.html')" />_______<input name="customer" type="text" size="16">___/customer/<br>
    </form>
    </body>
    </html>
    
    [formpop.html]
    Code:
    
    <html>
    <head>
    <title>*** Select Customer ***</title>
    <script type="text/javascript">
    
    function transfer_to_opener(oSelect, sDestFormName)
    {
    	if (opener && !opener.closed)
    	{
    		if (oSelect.selectedIndex < 0)
    			if (confirm('Select a customer?'))
    				return;
    			else self.close();
    		var opener_field, selval = oSelect.options[oSelect.selectedIndex].value;
    		opener_field = opener.document.forms[sDestFormName].elements[oSelect.name];
    		if (opener_field)
    			opener_field.value = ' ' + selval; //pad a bit
    	}
    	self.close();      
    }
    
    </script>
    </head>
    <body bgcolor="#82a4c8">
    <form name="popForm">
    <select name="customer" size="7">
    <option value="Al Cohen">Al Cohen</option>
    <option value="Betty Rubble">Betty Rubble</option>
    <option value="Paul Wolfowitz">Paul Wolfowitz</option>
    <option value="The Rock">The Rock</option>
    <option value="Madonna">Madonna</option>
    <option value="King Kong">King Kong</option>
    <option value="salmanucit">salmanucit</option>
    </select>
    <input type="button" value="done" onclick="return transfer_to_opener(customer, 'mainform')">
    </form>
    </body>
    </html>
    
    In practice, formpop.html would be a PHP-generated page with the customer names picked up from the database, as you said, and used to populate the drop-down. Could also use links/radio here. Give the select the same name as the 'destination' textfield. htw
    ::: certified wild guess :::


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
  •