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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

passing data from one page to another

Status
Not open for further replies.

dancinOTG

Technical User
Aug 28, 2002
19
CA
Ok I have 2 pages both are asp pages.

On the registration form i have a button that when clicked opens up a pop up window with a list of icons that can be chosen from a database (this part works perfectly). I have populated the textbox on this page from the database.

Now my users can choose one of the icons click submit next to it and .... this is where i'm having problems.

What this script is suppose to do is write the value from the text box on the icon page to the parentpage(regform) text box.

but i keep getting error saying that its not null or an object?

First page I have the following javascript
<script language=&quot;javascript&quot;>
function openMe(){
var x=window.open('show.asp', 'newWindow',
'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=300,height=500,left = 300,top = 50');
}
</script>
'with the following input buttons in the formitself

<INPUT type=button value=&quot;Open It&quot; name=submit1 onClick=&quot;openMe();&quot;><p><input type=&quot;text&quot; name=&quot;theBox&quot; size=&quot;20&quot;>

on the pop up window i have the following
<script language=&quot;javascript&quot;>
function setOther(){
window.opener.theForm.theBox.value=
document.myForm.thisBox.value;
}
</script>
<form method=&quot;POST&quot; name=&quot;myForm&quot;>
<p>
<input type=&quot;text&quot; name=&quot;thisBox&quot; size=&quot;5&quot; value=&quot;<%=FP_FieldVal(fp_rs,&quot;IconID&quot;)%>&quot;><input type=&quot;submit&quot; value=&quot;Choose&quot; name=&quot;B1&quot; onClick=&quot;setOther()&quot;;></p>
</form>

what am i doing wrong?
any help would be appreciated

frustratedDancin
 
hi dancinOTG,

this:
function setOther(){
window.opener.theForm.theBox.value=
document.myForm.thisBox.value;
}


should be this:
function setOther(){
window.opener.document.theForm.theBox.value=
document.myForm.thisBox.value;
}
=========================================================
if (!succeed) try();
-jeff
 
Thankyou jeff
but i'm still getting a runtime error that says

a runtime error has occurred
Line 10
'document.myForm.thisBox.value'is null or not an object

:(
 
i have it writing to the parent page
but its writing the whole string.... ie... document.myForm.thisBox.value

instead of the value

gettin there in bits and bytes lol

sigh i just want the VALUE to show in the text box on the parent page but danged if i can figure out why its not

as you probably noticed i'm new to this

any help would be appreciated

dancin
 
It sounds like you have the reference to the form element value in quotations. Show a copy of the function, don't retype it for the forum.
 
<script language=&quot;javascript&quot;>
function setOther()
{
window.opener.document.theForm.theBox.value=
'document.myForm.thisBox.value';
}
</script>

this is the function
it writes the whole 'document.myForm etc. line into the text box on the parent page.

dancin
 
To solve your problem, you can also use the
Code:
retvalue = window.showmodalDialog(..)[\code] method in your parent page and then set the [code]returnValue = document.myForm.thisBox.value[\code] in the [code]setOther()[\code] function of your opened popup.
 Water is not bad as soon as it stays out human body ;-)
 
dancin,

trollacious is right:

change this
<script language=&quot;javascript&quot;>
function setOther()
{
window.opener.document.theForm.theBox.value=
'document.myForm.thisBox.value';
}
</script>


to this
<script language=&quot;javascript&quot;>
function setOther()
{
window.opener.document.theForm.theBox.value =
document.myForm.thisBox.value;
}
</script>


this will work, provided your opener has a form named &quot;theForm&quot; and a field named &quot;theBox&quot;, and the child window has a form named &quot;myForm&quot; and a field named &quot;thisBox&quot; =========================================================
if (!succeed) try();
-jeff
 
Thanks again ev1

Ok I took everything you said and decided to try it out by making 2 new pages with .htm extensions and lo and behold the
document.myForm.thisBox.value

worked perfectly.

Now the question is why isn't it working on my two asp pages?

same function same script exactly (cept the page names have been changed to protect the innocent *s*)
but it is giving me the
error document.myForm.thisBox.value is null or not an object

now the value in thisBox is called from a database using<%FP_FieldVal(fp_rs,(&quot;IconId&quot;)%>

so when the page opens it has the text box with the icon id number already in it.

all the user has to do is press submit but thats when the error comes in.

feelin very blonde today :))
dancin
 
hi dancin,

show the actual ASP code.

=========================================================
if (!succeed) try();
-jeff
 
hi jeff been a busy couple of days

ok this is the asp

<%
fp_sQry=&quot;SELECT * FROM ICON ORDER BY IconID ASC&quot;
fp_sDefault=&quot;&quot;
fp_sNoRecords=&quot;<tr><td colspan=2 align=left width=&quot;&quot;100%&quot;&quot;>No records returned.</td></tr>&quot;
fp_sDataConn=&quot;dancin&quot;
fp_iMaxRecords=256
fp_iCommandType=1
fp_iPageSize=0
fp_fTableFormat=True
fp_fMenuFormat=False
fp_sMenuChoice=&quot;&quot;
fp_sMenuValue=&quot;&quot;
fp_iDisplayCols=2
fp_fCustomQuery=False
BOTID=0
fp_iRegion=BOTID
%>
<!--#include file=&quot;_fpclass/fpdbrgn1.inc&quot;-->
<!--webbot bot=&quot;DatabaseRegionStart&quot; i-checksum=&quot;62621&quot; endspan -->
<tr>
<td>
<form method=&quot;POST&quot; name=&quot;myForm&quot;>
<input type=&quot;text&quot; name=&quot;thisBox&quot; value=&quot;<%=FP_FieldVal(fp_rs,&quot;IconID&quot;)%&quot;>
<input type=&quot;hidden&quot; name=&quot;Icon&quot; value=&quot;<%=FP_FieldValfp_rs,(&quot;Icon&quot;)%>&quot;>
<input type=&quot;submit&quot; value=&quot;Choose&quot; name=&quot;B1&quot; onClick=&quot;setOther()&quot;;>
</form>
</td>
<td><img border=&quot;0&quot; src=&quot;images/<%=FP_FieldLink(fp_rs,&quot;Icon&quot;)%>&quot;></td>
</tr>

and again the javascript is:
<script language=&quot;javascript&quot;>
function setOther()
{
window.opener.document.theForm.theBox.value =
document.myForm.thisBox.value;
}
</script>

dancin

 
Below you will find the way you can pass info from one window to another:

adppa1_3_4_6_8.htm?adppa6

Anything after the ? is the info you pass to the next window...

to retrieve this info in the next window you need to search the location with this snippet below:

location.search.substr(1);

This will give anything after the ?...

Hope this help...
 
hi dancin,


this error would be caused when the script can't find the object you're asking for...usually because something is misspelled, or if you try to access an object before page has finished loading...

is this script actually on the page itself?
[tt]
<script language=&quot;javascript&quot;>
function setOther()
{
window.opener.document.theForm.theBox.value =
document.myForm.thisBox.value;
}
</script>

[/tt]

do you try to call setOther() elsewhere before the page has finished loading?



=========================================================
if (!succeed) try();
-jeff
 
:)
this exact script works on .html pages where a user types a number into the text box... the setOther() on the parent window works perfectly.

on my asp pages where the value of thisBox=&quot;<FP_rs FieldVal,(fp_rs(&quot;IconId&quot;)%>&quot;> i get the error...

When you see the child window it has a table with icon id numbers and a pic beside it drawn from a database,the field value number is placed into the text box by the query to the database but the setOther() doesn't seem to recognize this

I hate to give up on this idea but it seems like i will have to have my users just look at the table and manually enter the number of the icon they want in the parent window.
(but :( from past past reg forms i've done you'd be amazed how anything that requires thought on the part of the users usually confuses them.. not all but you'd be amazed lol)


thanks for your help though :)

htfsm.gif
 
hmm...is the value actually being populated correctly? what are the values possible for FP_rs FieldVal,(fp_rs(&quot;IconId&quot;)?

=========================================================
if (!succeed) try();
-jeff
 
The values are numbers... ie 1,2,3,4,5 etc. (these are the primary key (autonumbers) from an access database.) and they are populating the text box correctly as 1,2,3,4, etc.

dancin
[wink]
 
The following line, copied from the example you typed in above, has an error in it in the closing ASP symbol(s):

<input type=&quot;text&quot; name=&quot;thisBox&quot; value=&quot;<%=FP_FieldVal(fp_rs,&quot;IconID&quot;)%&quot;>

If you DIDN'T copy your code exactly into the forum, please ONLY do so in the future because this is all we have to go on to help you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top