Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Jan 2007
    Posts
    13
    Thanks
    2
    Thanked 0 Times in 0 Posts

    onClick() and other help

    I have a simple page with a form that looks something like this:

    form.php:
    Code:
    <html>
    <head>
    	<script type="text/javascript"><!--
    	function ShowMemberlist() {
    		window.open("<?php echo $domain; ?>/pages/popup.php", "memberlist", "status=1,toolbar=0,location=0,menubar=0,directories=0,resizable=0,scrollbars=1,height=250,width=250");
    	}
    
    	function SelectUser(formName, obj, val) {
    		opener.document.forms[formName].elements[obj].value = val;			self.close();
    	}
    	--></script>
    </head>
    <body>
    <form name="compose_pm" action="submit.php" method="POST">
    <b>User Name:</b> <input id="user_name" name="user_name" type="text"> &nbsp; (<a href="ShowMemberlist()">Find a member</a>)<br />
    <input name="submit" type="submit" value="Find!">
    </form>
    </body>
    </html>
    Then...
    popup.php:
    Code:
    <script type="text/javascript"><!--
    	document.write ('<a href="#" onclick="SelectUser(\'compose_pm\', \'user_name\', \'User_1\'); return false">Select<'+'/a>');
    --></script>
    &nbsp; User_1 &nbsp; Text
    Here's what I'm trying to achieve.

    A user goes to form.php and clicks on "Find a member" which opens up a popup window of popup.php. The user finds the user name he/she wants, and clicks on "Select". Javascript then should close the popup window, and put the value (which in this case is "User_1") into the appropriate input box. Currently, this script is not working. How would I make this work? Help is appreciated.

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,037
    Thanks
    0
    Thanked 250 Times in 246 Posts
    The SelectUser() function should be in the popup.php not in form.php. And the "Find a member" link should be like this:
    Code:
    <a href="#" onclick="ShowMemberlist(); return false;">Find a member</a>

  • #3
    New Coder
    Join Date
    Jan 2007
    Posts
    13
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Ok, that helped. Thank you very much.


  •  

    Posting Permissions

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