...

View Full Version : onClick calling function



padraigosca
08-09-2005, 09:52 AM
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>

jbot
08-09-2005, 10:56 AM
is the form in a popup, per chance? is the function also in the same popup?

jbot
08-09-2005, 11:03 AM
ok ... try this (notice the correct HTML):


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();
}




<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>

padraigosca
08-09-2005, 11:05 AM
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.

jbot
08-09-2005, 11:09 AM
^^ see previous post. hope that helps :thumbsup:

padraigosca
08-09-2005, 11:24 AM
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.

padraigosca
08-09-2005, 03:52 PM
Sorry for wasting everyone's time, problem was in the code I didn't add.. A day wasted.. :mad:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum