Click to See Complete Forum and Search --> : new helps on pop-up form


fish
02-10-2003, 08:34 PM
I'm definately new to js and I need help on this simple coding.

I have a form with an input box, say member id, that is required to be filled. Beside the box, I have a search button to pop-up another form (small one) so the user can search for info if they don't know what to put in the first box. If found after the usual search routine, the user click submit, the small box closes and the value goes to the input box in the big form. Simple but I don't know how to do, woe....

I'm sure someone or somewhere these codes have been answered or shown. Sorry I have such a slow bandwidth that searching for it can be quite painfully slow.

Just need a sample (with 1 field) if anyone can help. Appreciate it and thanks.

pyro
02-10-2003, 09:40 PM
To move information from a form in a popup window to a form in the parent window, try inserting something like this in your popup window:

function move()
{
window.opener.formname.inputname.value = document.formname.inputname.value;
}

<body onUnload="move()">

Where item's in bold are changed to reflect your page.

fish
02-12-2003, 07:48 PM
Thanks Pyro for the method. I tried your method as below. Please tell me why this doesn't work.


------- FormX.htm-------
<script language="javascript">
function gotoformY()
{
window.open('FormY.htm','popuppage','width=300,height=200,top=50,left=100');
}
</script>

<Form name=form1 method=post action=somewhere.asp>
Member Name: <INPUT name="mname">&nbsp;<INPUT name=btnsubmit type=button value=Search onclick="gotoformY();">
</Form>

------- FormY.htm-------
<script LANGUAGE="javascript">
//-->
function name_onClick() {

x = "FormX.htm";
window.form2.action=x;
window.opener.form1.mname = document.form2.fname.value;
window.close;
window.document.form2.submit();

}
//-->
</script>

<Form name=form2 method=post>
Jim James <INPUT type=radio name="fname" value="jj" onClick="name_onClick()">
</Form>

Thanks.
Ps: I'm still learning.....

pyro
02-12-2003, 08:10 PM
Try changing this

window.opener.form1.mname = document.form2.fname.value;

to this

window.opener.form1.mname.value = document.form2.fname.value;

and, you can remove these lines

x = "FormX.htm";
window.form2.action=x;
window.document.form2.submit();


as they shouldn't be necessary.

fish
02-12-2003, 09:42 PM
Thank you, Pyro for your prompt reply and help.
I tried your suggestion and it works great. Now, my final problem.

my window.close doesn't seem to work. Meaning I can't close the window after copying the data from my search form to the main form. I can work around it by putting a "Close" button there but I prefer it to automatically close down after select.

Please suggest.

Thanks again.

pyro
02-12-2003, 10:01 PM
window.close;
should be
window.close();

Cheers... :D

fish
02-12-2003, 10:17 PM
Oops!! What a joke.

Looks like Javascript is not as easy as it seems. No error messages and just plain refuse to bug. And I was staring at it for a long while and can't even figure out why it doesn't work. It's the stupid brackets, damn.


Thanks Pyro for pointing out the obvious. Owe you one and Keep up the good work.

:p