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 7 of 7
  1. #1
    New to the CF scene
    Join Date
    Jun 2005
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    onClick calling function

    Hi, I have a Javascript function that when called, sends values to its parent window. But for some reason the onClick command does not call the function.
    Any help would be appreciated.


    function SendCustomer(count)
    {
    var txtVal = document.forms["formPop"]["name"+count].value;
    var txtVal1 = document.forms["formPop"]["id"+count].value;
    var txtVal2 = document.forms["formPop"]["number"+count].value;
    window.opener.document.forms["esg"].elements["customer_name"].value = txtVal;
    window.opener.document.forms["esg"].elements["customer_id"].value = txtVal1;
    window.opener.document.forms["esg"].elements["customer_number"].value = txtVal2;
    window.close();
    }
    +========================================+
    <FORM NAME="formPop" action =" " method =" post">
    <input type ="text" name="search" size="30"><br>
    <input type =" submit" name="submit" value="search">

    <input type=button Value=Select onclick=SendCustomer(1);>
    <input type='text' name='name1'value='Paddy Power'readonly>
    <input type ='hidden' name='id1'value='5'>
    <input type=text name='number1' value='086 4545451'readonly>
    </form>

  • #2
    Senior Coder
    Join Date
    Feb 2004
    Location
    Edinburgh
    Posts
    1,352
    Thanks
    0
    Thanked 0 Times in 0 Posts
    is the form in a popup, per chance? is the function also in the same popup?
    *keep it simple (TM)

  • #3
    Senior Coder
    Join Date
    Feb 2004
    Location
    Edinburgh
    Posts
    1,352
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ok ... try this (notice the correct HTML):

    Code:
    function SendCustomer(oFld,oFrm,iCount)
    {
    	var txtVal = oFrm["name"+iCount].value;
    	var txtVal1 = oFrm["id"+iCount].value;
    	var txtVal2 = oFrm["number"+iCount].value;
    	var oWinFrm = window.opener.document.forms["esg"];
    
    	oWinFrm.customer_name.value = txtVal;
    	oWinFrm.customer_id.value = txtVal1;
    	oWinFrm.customer_number.value = txtVal2;
    	window.close();
    }


    Code:
    <form name="formPop" method="post">
    	<input type="text" name="search" size="30">
    	<br>
    	
    	<input type="submit" name="submit" value="search">
    	<input type="button" Value="Select" onclick="SendCustomer(this,this.form,1);">
    	
    	<input type="text" name="name1" value="Paddy Power" readonly>
    	<input type="text" name="number1" value="086 4545451" readonly>
    	
    	<input type="hidden" name="id1" value="5">
    </form>
    Last edited by jbot; 08-09-2005 at 11:08 AM.
    *keep it simple (TM)

  • #4
    New to the CF scene
    Join Date
    Jun 2005
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yes the form is in the pop up, and the function is on the same page as the form.

    The page works by having one page with one form, and the option to bring up a pop up with another form that searches a database.
    On the pop up, the user clicks on the button next to the value they wish to return to the parent window.

  • #5
    Senior Coder
    Join Date
    Feb 2004
    Location
    Edinburgh
    Posts
    1,352
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ^^ see previous post. hope that helps
    *keep it simple (TM)

  • #6
    New to the CF scene
    Join Date
    Jun 2005
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Unfortunatly not, i have similar code working on another page, and it works no problem. Thanks for your help anyway. I'll post the code if I figure it out.

  • #7
    New to the CF scene
    Join Date
    Jun 2005
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Sorry for wasting everyone's time, problem was in the code I didn't add.. A day wasted..


  •  

    Posting Permissions

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