/    Sign up×
Community /Pin to ProfileBookmark

HELP PLEASE! – Passing form fields to pop window

—I am trying to pass a value from a pop-up to the previous page and I am having some issues…—

[B]ON THE MAIN PAGE:[/B]

<a href=”javascript:merge1.popup();”><img src=”_Images/Btn_Search_Green.jpg” border=”0″></a>

<a href=”javascript:merge2.popup();”><img src=”_Images/Btn_Search_Green.jpg” border=”0″></a>

<script language=”Javascript”>
var merge1 = new calendar(document.forms[‘Form1’].elements[‘FacClaSeqA’]);
var merge2 = new calendar(document.forms[‘Form1’].elements[‘FacClaSeqB’]);

var calendars = [];

function calendar(obj_target) {
this.popup = cal_popup1;
this.target = obj_target;
this.id = calendars.length;
calendars[this.id] = this;
}

function cal_popup1 () {
var obj_calwindow = window.open(‘SearchNegotiation.aspx?MergeSearch=Y&Client=SAS’,’Search’,’width=800,height=600,top=10,scrollbars=1,toolbar=0,status=no,resizable=1,menubar=0′);
obj_calwindow.opener = window;
obj_calwindow.focus();
}

</script>

[B]ON THE POP UP WINDOW:[/B]

–This page is a form where you search for a specfic claim and when the claim list is displayed you can click on the link below to return back to the main page.–

<script language=”Javascript”>
var re_url = new RegExp(‘datetime=(-?d+)’);
var dt_current = (re_url.exec(String(window.location)) ? new Date(new Number(RegExp.$1)) : new Date());
var re_id = new RegExp(‘id=(d+)’);
var num_id = (re_id.exec(String(window.location)) ? new Number(RegExp.$1) : 0);
var obj_caller = (window.opener ? window.opener.calendars[num_id] : null);

function returnSearch(value) {
window.close();
obj_caller.target.value = (value);
}
</script>

<a href=’javascript:returnSearch(” + sFacClaSeq + “);’>Link</a>

–When I submit the form I lose my initial return to field and when the pop-up window closes it just displays the info in the first text field available instead of the field it’s supposed to.

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@CrazyMerlinJan 09.2006 — in your pop up window, you need to write back to the parent page before you close the popup

set a variable to reference the object you are writing to on the parent page:

var thisObject = window.opener.document.getElementById('NAMEOFTARGET');

then simply control it as you like...to set it's value:

thisObject.value=value;
Copy linkTweet thisAlerts:
@webqueen79authorJan 10.2006 — I am not having a problem returning the value to the main page, I am having a problem keeping the variable of what field it's supposed to return the value to when the form submits in the pop-up.....???
Copy linkTweet thisAlerts:
@CrazyMerlinJan 10.2006 — why are you using the 'this' keyword inside your function?

'this' is a special keyword, only relevant when passing value 'to' a function.

you need to pass a reference of the target to a variable in the popup window, which you are not doing.

try this...

in you popup window, make:

var RecTarget = "";


then in your function declaration:

function cal_popup1 (myTarget){

.

.

obj_calwindow.RecTarget = myTarget;

.

.

}

you should now have a reference to the target object in you popup window.

pass the target from your other function if you need to.

the 'this' keyword, as it stands, is refering to your function, not any target.

'this' refers to it's direct owner.

hope this helps
Copy linkTweet thisAlerts:
@webqueen79authorJan 10.2006 — This is what I have now and it is still not working.. AHH! I can't figure this thing out...

In the main window:

//Call the popup window

<a href="javascript:cal_popup1('FacClaSeqA');">

//Script that displays the pop-up window

<script language="javascript">

var calendars = [];

function cal_popup1(obj_target) {

var RecTarget = "";

var obj_calwindow = window.open('SearchNegotiation.aspx?MergeSearch=Y&Client=SAS','Search','width=800,height=600,top=10,scrollbars=1,toolbar=0,status=no,resizable=1,menubar=0');

obj_calwindow.RecTarget = obj_target;

obj_calwindow.opener = window;

obj_calwindow.focus();

}

</script>

In the Pop-up window:

//Script that returns back to main window

<script language="javascript">

var re_url = new RegExp('datetime=(-?d+)');

var dt_current = (re_url.exec(String(window.location)) ? new Date(new Number(RegExp.$1)) : new Date());

var re_id = new RegExp('id=(d+)');

var num_id = (re_id.exec(String(window.location)) ? new Number(RegExp.$1) : 0);

var obj_caller = (window.opener ? window.opener.calendars[num_id] : null);

function returnSearch(value) {

window.close();

obj_caller.target.value = (value);

}

</script>

//Link they click to get back to main window

<a href='javascript:returnSearch(" + sFacClaSeq + ");'>Link</a>
×

Success!

Help @webqueen79 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 5.6,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

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