Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

parse data

Status
Not open for further replies.

Mygurutech

IS-IT--Management
Mar 24, 2008
10
NL
hi
I want to parse the values of a popup form to the mainform.

From the popup form I only need a value of a listbox and put this value to a textbox of the mainform.

My question is how can I do this?
I working with asp and MS access database.
Could you please advise how to do this?

Many thanks
Rajesh
 
When you open the popup, you'd need to store a handle to the window. This is returned by the window.open call you'll be using to open the popup.

Using this handle, you can access the form elements in the popup by the form name:

Code:
var theFrmEls = popupHandle.document.forms['yourFormName'].elements;

And then using the select element name, access its properties:

Code:
var selIndex = theFrmEls['selectElName'].selectedIndex;

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Dan,
from your coding I can imaging it will work...but..could please help me with step by step how to make this workable

advice:
from the pop up page I have to call this:

var theFrmEls = popupHandle.document.forms['yourFormName'].elements;
and than
var selIndex = theFrmEls['selectElName'].selectedIndex;
after this

how the main page with grab the value?

Please explain.
Rajesh
 
You don't need to do anything from the popup page at all. You do it all from the opener.

When you open your popup window, store the returned handle:

Code:
var popupHandle = window.open(...

That is the handle you use with the other code above to allow you to read from the popup window's form.

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
you could also do it from the child window and use something like :

opener.document.forms['yourFormName'].<field name>.value="123"



Greg Griffiths
Livelink Certified Developer & ECM Global Star Champion 2005 & 2006
 
Hi there
Both not working
Main page = epr.asp
child page = loc.asp

You have to know that first I have to select the particular value from a listbox (from the pop up page LOC.asp)and after I made my selection the value
should come to the main page (epr.asp) (location textbox).

on the Loc.aps page I have put

<script language=javascript>
document.write(window.opener.document.forms["frepr"].Location.value);
</script>

But still not working...

Do have any advice?/ suggestions?
Brgds Rajesh
 
If you want to push the value from the popup to the main window, as opposed to pulling the value from the popup to the main window, then use Greg's solution.

It's much the same, but you no longer need to store the window handle any more. On the select element in the popup, add an "onchange" call:

Code:
<select name="whatever" onchange="pushValue(this);">

And then create a "pushValue" function in the popup's script section:

Code:
function pushValue(selObj) {
   var theValue = '';
   if (selObj.selectedIndex != -1) {
      theValue = selObj.options[selObj.selectedIndex];
   }
   window.opener.document.forms['mainWindowFormName'].elements['mainWindowTextElName'].value = theValue;
}

Obviously, you'll need to replace mainWindowFormName and mainWindowTextElName accordingly.

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
hi Dan,
I think coding is little incorrect..but
when I changed the value...i received on the mainform in the textbox instead of the value..

[object]

don't know what is means...

how to fix...
please advise
Rajesh
 
[tt]theValue = selObj.options[selObj.selectedIndex][!].value[/!];[/tt]

[sub]Never be afraid to share your dreams with the world.
There's nothing the world loves more than the taste of really sweet dreams.
[/sub]

Webflo
 
hi guys,
Many thx helping me out fixing this..
very helpful and finally I can put my little application LIVE.

Brgds
Rajesh
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top