/    Sign up×
Community /Pin to ProfileBookmark

new helps on pop-up form

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.

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@pyroFeb 11.2003 — 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.[b]formname.inputname[/b].value = document.[b]formname.inputname[/b].value;

}

<body onUnload="move()">

Where item's in [b]bold[/b] are changed to reflect your page.
Copy linkTweet thisAlerts:
@fishauthorFeb 13.2003 — 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.....
Copy linkTweet thisAlerts:
@pyroFeb 13.2003 — Try changing this

[font=monospace]window.opener.form1.mname = document.form2.fname.value;[/font]

to this

[font=monospace]window.opener.form1.mname.value = document.form2.fname.value;[/font]

and, you can remove these lines

[font=monospace]x = "FormX.htm";

window.form2.action=x;

window.document.form2.submit();[/font]


as they shouldn't be necessary.
Copy linkTweet thisAlerts:
@fishauthorFeb 13.2003 — 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.
Copy linkTweet thisAlerts:
@pyroFeb 13.2003 — [font=monospace]window.close;[/font]

should be

[font=monospace]window.close();[/font]

Cheers... ?
Copy linkTweet thisAlerts:
@fishauthorFeb 13.2003 — 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
×

Success!

Help @fish spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...