HTML, JavaScript And CSS Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingHTML, JavaScript And CSS Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old July 1st, 2008, 01:36 PM
cooperljrh cooperljrh is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2006
Location: Jacksonville
Posts: 282 cooperljrh User rank is Sergeant (500 - 2000 Reputation Level)cooperljrh User rank is Sergeant (500 - 2000 Reputation Level)cooperljrh User rank is Sergeant (500 - 2000 Reputation Level)cooperljrh User rank is Sergeant (500 - 2000 Reputation Level)cooperljrh User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 2 Days 1 h 34 m 51 sec
Reputation Power: 9
Send a message via AIM to cooperljrh Send a message via Yahoo to cooperljrh
Problem with populating opener fields from pop up

Hey all!

one of our interoffice online forms has 9 fields (name, address...) the primary key is the resident's "number" (RN) -- which all are 8 digits with 4 leading zeros.

when we fill out these forms, we have to type their name, their address, all the fields out -- which seems tedious because all the information is in a db. (i know this is javascript forum and not db, but its a javascript problem/question, not a db one -- oh, and access db...not that that part matters...)

so to streamline this process, what i have done is added a link beside the RN input that says "populate" when you click the link, a little window opens that just has an input field for their number, and then a submit button.

when you enter the RN, and hit submit it queries the database to see if they are in the db. if they are, it takes the fields we need and compiles the following function:

Code:
function setMasterControl(strInput)
    {
        opener.document.form.name1.value = 'Last, First';
        opener.document.form.N1.value = '00005355';
        opener.document.form.bldg1.value = 'W';
        opener.document.form.room1.value = '119';
        opener.document.form.hb1.value = '1003';
        opener.document.form.phone1.value = '(999) 999-9999';
        opener.document.form.DOB1M.value = '10';
        opener.document.form.DOB1D.value = '4';
        opener.document.form.DOB1Y.value = '1989';
        window.close();
    }


so after the database has been queried, and the function populated, the only thing that displays on the screen is "Success!" and a button to execute setMasterControl function

Code:
<input type="button" value="Import Resident" onClick="setMasterControl();">


ive been playing with it for a while...i tried adding the true forms name (finalMonth) instead of "form," ive tried another type of the same function that has all the variables in the button and when it calls the function it feeds them in, and ive tried not feeding any variables in, but it still doesnt work (and by not work, i mean that the little pop up doesnt close and the opener form isnt populated with the fields).

im not sure if i am missing something little, or something BIG! so any tips or pointers would be great!

Reply With Quote
  #2  
Old July 1st, 2008, 06:34 PM
markoc's Avatar
markoc markoc is offline
Contributing User
ASP Free Regular (2000 - 2499 posts)
 
Join Date: Nov 2003
Location: UK
Posts: 2,151 markoc User rank is First Lieutenant (10000 - 20000 Reputation Level)markoc User rank is First Lieutenant (10000 - 20000 Reputation Level)markoc User rank is First Lieutenant (10000 - 20000 Reputation Level)markoc User rank is First Lieutenant (10000 - 20000 Reputation Level)markoc User rank is First Lieutenant (10000 - 20000 Reputation Level)markoc User rank is First Lieutenant (10000 - 20000 Reputation Level)markoc User rank is First Lieutenant (10000 - 20000 Reputation Level)markoc User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 18 h 10 m 15 sec
Reputation Power: 201
Problem with populating opener fields from pop up

you missed window at the beginning of the form object to return to.

so it's not:

Code:
opener.document.....


it should be:

Code:
window.opener.document.....
__________________
Hope this advise helps.

If so please show your appreciation by adding reputation points (click gauge image on top right of this post and score).

Reply With Quote
  #3  
Old July 2nd, 2008, 12:25 PM
ChiefWigs1982's Avatar
ChiefWigs1982 ChiefWigs1982 is offline
Cunning Linguist
ASP Free Loyal (3000 - 3499 posts)
 
Join Date: Mar 2005
Location: I used to live at home, now I stay at the house
Posts: 3,385 ChiefWigs1982 User rank is Major (30000 - 40000 Reputation Level)ChiefWigs1982 User rank is Major (30000 - 40000 Reputation Level)ChiefWigs1982 User rank is Major (30000 - 40000 Reputation Level)ChiefWigs1982 User rank is Major (30000 - 40000 Reputation Level)ChiefWigs1982 User rank is Major (30000 - 40000 Reputation Level)ChiefWigs1982 User rank is Major (30000 - 40000 Reputation Level)ChiefWigs1982 User rank is Major (30000 - 40000 Reputation Level)ChiefWigs1982 User rank is Major (30000 - 40000 Reputation Level)ChiefWigs1982 User rank is Major (30000 - 40000 Reputation Level)ChiefWigs1982 User rank is Major (30000 - 40000 Reputation Level)  Folding Points: 50746 Folding Title: Beginner FolderFolding Points: 50746 Folding Title: Beginner FolderFolding Points: 50746 Folding Title: Beginner Folder
Time spent in forums: 1 Month 1 Week 3 Days 8 h 42 m 5 sec
Reputation Power: 307
Facebook
Quote:
Originally Posted by markoc
you missed window at the beginning of the form object to return to.
That doesn't really matter - you don't need the window prefix.

Cooperljrh, can you confirm a few things? It might help if you were
to post more of your code...

The function you have posted - that is executed inside the popup
window, not the opener window, right?

If the form is called "finalMonth", then you should access it using
that name - "document.form" will not do.
Code:
opener.document.forms["finalMonth"].whatever
When you did that, did you get any error messages?

Why are you taking the variable "strInput" into the function?
__________________
Support requests via PM will be ignored!
Route of Queue | The General FAQ Thread | HOW TO POST A QUESTION

Sign up with Matched.co.uk and earn up to £15 per website every month!


Reply With Quote
  #4  
Old July 2nd, 2008, 01:25 PM
cooperljrh cooperljrh is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2006
Location: Jacksonville
Posts: 282 cooperljrh User rank is Sergeant (500 - 2000 Reputation Level)cooperljrh User rank is Sergeant (500 - 2000 Reputation Level)cooperljrh User rank is Sergeant (500 - 2000 Reputation Level)cooperljrh User rank is Sergeant (500 - 2000 Reputation Level)cooperljrh User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 2 Days 1 h 34 m 51 sec
Reputation Power: 9
Send a message via AIM to cooperljrh Send a message via Yahoo to cooperljrh
Quote:
Originally Posted by ChiefWigs1982
That doesn't really matter - you don't need the window prefix.

(etc.)


Chief -- yes, the function is in the pop up, not the parent.

and as for more code, this is the entire pop up code -- where i am after the RN has queried the db, found a match, and ready to import the fields to the parent:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Import RN</title>
<style type="text/css">
	* {
		font-family: Georgia, "Times New Roman", Times, serif;
	}
</style>
<script language="JavaScript">
<!--
function setMasterControl()
	{
		window.opener.document.forms["form"].name1.value = '[resident name]';
		window.opener.document.form["form"].N1.value = '[RN]';
		window.opener.document.form["form"].bldg1.value = '[bldg]';
		window.opener.document.form["form"].room1.value = '[room]';
		window.opener.document.form["form"].hb1.value = '[mailbox]';
		window.opener.document.form["form"].phone1.value = '[phone]';
		window.opener.document.form["form"].DOB1M.value = '[dob_m]';
		window.opener.document.form["form"].DOB1D.value = '[dob_d]';
		window.opener.document.form["form"].DOB1Y.value = '[dob_y]';
		window.close();
}
// -->
</script>

</head>
<body>
<table width="189" border="0" align="center" cellpadding="2" cellspacing="2">

 	<tr>
    	<td align="center">Success!</td>
    </tr>
    <tr>
    	<td align="center"><input type="button" value="Import Information" onClick="javascript:setMasterControl();"><br>
        <a href="#" onClick="setMasterControl();">Import Information</a></td>
   	</tr>
            
</table>
</body>
</html>

(please note: all [fields] in function are properly displayed in the true function but have been removed for the above example)

neither the button, nor the link properly execute the function...nor do i receive any errors. (i might have in the pop up, if disabling the status bar prevents you from receiving the error alert)

now this is the parent page code:
Code:
<form name="form" action="[document]?step=3" method="post" onSubmit="return checkForm2(this);">
  
 	<table border="0" align="center" cellpadding="2" cellspacing="0" style="width: 440px; font-size: 12px; font-family: Verdana, Arial, Helvetica, sans-serif;">
        <tr>
          <td>Individual 1:</td>
          <td><input name="name1" type="text" id="name1" size="30" maxlength="50"></td>
        </tr>
        <tr>
          <td>RN Number:</td>
          
          <td><input name="N1" type="text" id="N1" size="9" maxlength="9"> 
          <img src="/images/import.jpg" width="35" height="13" border="0" onClick="window.open('[pop up document]?which=1&i=1', '22', 'width=200,height=100,status=no');"></td>
        </tr>
        <tr>
          <td>Building:</td>
          <td><select name="bldg1" id="bldg1">
          	<option value="A" selected="selected">A</option>
          	<option value="B">B</option>
          	<option value="C">C</option>
          	<option value="D">D</option>
          	<option value="E">E</option>
          	<option value="F">F</option>
          	<option value="G">G</option>
          	<option value="Q">Q</option>
          	<option value="R">R</option>
          	<option value="S">S</option>
          	<option value="T">T</option>
          	<option value="U">U</option>
          	<option value="V">V</option>
          	<option value="W">W</option>
          	<option value="X">X</option>
          	<option value="Y">Y</option>
          	<option value="Z">Z</option>
          </select></td>
        </tr>
        <tr>
          <td>Room:</td>
          <td><input name="room1" type="text" id="room1" size="5" maxlength="3" /></td>
        </tr>
        <tr>
          <td>HB:</td>
          <td><input name="hb1" type="text" id="hb1" size="5" maxlength="4" /></td>
        </tr>
        <tr>
          <td align="right" bgcolor="#DADADA">Address <span style="font-size: 9px; font-style: italic;">(if non-resident)</span>:</td>
          <td bgcolor="#DADADA"><input name="address11" type="text" id="address11" size="30" maxlength="50" />
          <br /></td>
        </tr>
        <tr>
          <td align="right" bgcolor="#DADADA">City, State Zip</td>
          <td bgcolor="#DADADA"><input name="address21" type="text" id="address21" size="30" maxlength="50" /></td>
        </tr>
        <tr>
          <td>Phone:</td>
          <td><input name="phone1" type="text" id="phone1" size="20" maxlength="20">
            <span style="font-size: 9px; color: #999999;"><br />
            format: 000-000-0000</span></td>
        </tr>
        <tr>
          <td>Date Of Birth:</td>
          <td>
          <select name="DOB1M">
          	
	          	<option value="1">1</option>
           	
	          	<option value="2">2</option>
           	
	          	<option value="3">3</option>
           	
	          	<option value="4">4</option>
           	
	          	<option value="5">5</option>
           	
	          	<option value="6">6</option>
           	
	          	<option value="7">7</option>
           	
	          	<option value="8">8</option>
           	
	          	<option value="9">9</option>
           	
	          	<option value="10">10</option>
           	
	          	<option value="11">11</option>
           	
	          	<option value="12">12</option>
           	
          </select>/<select name="DOB1D">
          	
	          	<option value="1">1</option>
           	
	          	<option value="2">2</option>
           	
	          	<option value="3">3</option>
           	
	          	<option value="4">4</option>
           	
	          	<option value="5">5</option>
           	
	          	<option value="6">6</option>
           	
	          	<option value="7">7</option>
           	
	          	<option value="8">8</option>
           	
	          	<option value="9">9</option>
           	
	          	<option value="10">10</option>
           	
	          	<option value="11">11</option>
           	
	          	<option value="12">12</option>
           	
	          	<option value="13">13</option>
           	
	          	<option value="14">14</option>
           	
	          	<option value="15">15</option>
           	
	          	<option value="16">16</option>
           	
	          	<option value="17">17</option>
           	
	          	<option value="18">18</option>
           	
	          	<option value="19">19</option>
           	
	          	<option value="20">20</option>
           	
	          	<option value="21">21</option>
           	
	          	<option value="22">22</option>
           	
	          	<option value="23">23</option>
           	
	          	<option value="24">24</option>
           	
	          	<option value="25">25</option>
           	
	          	<option value="26">26</option>
           	
	          	<option value="27">27</option>
           	
	          	<option value="28">28</option>
           	
	          	<option value="29">29</option>
           	
	          	<option value="30">30</option>
           	
	          	<option value="31">31</option>
           	
          </select>/<select name="DOB1Y">
          	
	          	<option value="1980">1980</option>
           	
	          	<option value="1981">1981</option>
           	
	          	<option value="1982">1982</option>
           	
	          	<option value="1983">1983</option>
           	
	          	<option value="1984">1984</option>
           	
	          	<option value="1985">1985</option>
           	
	          	<option value="1986">1986</option>
           	
	          	<option value="1987">1987</option>
           	
	          	<option value="1988">1988</option>
           	
	          	<option value="1989">1989</option>
           	
	          	<option value="1990">1990</option>
           	
	          	<option value="1991">1991</option>
           	
	          	<option value="1992">1992</option>
           	
	          	<option value="1993">1993</option>
           	
	          	<option value="1994">1994</option>
           	
	          	<option value="1995">1995</option>
           	
	          	<option value="1996">1996</option>
           	
	          	<option value="1997">1997</option>
           	
	          	<option value="1998">1998</option>
           	
	          	<option value="1999">1999</option>
           	
	          	<option value="2000">2000</option>
           	
          </select>
          </td>
        </tr>
    </table>  
    </form>

Reply With Quote
  #5  
Old July 2nd, 2008, 02:27 PM
ChiefWigs1982's Avatar
ChiefWigs1982 ChiefWigs1982 is offline
Cunning Linguist
ASP Free Loyal (3000 - 3499 posts)
 
Join Date: Mar 2005
Location: I used to live at home, now I stay at the house
Posts: 3,385 ChiefWigs1982 User rank is Major (30000 - 40000 Reputation Level)ChiefWigs1982 User rank is Major (30000 - 40000 Reputation Level)ChiefWigs1982 User rank is Major (30000 - 40000 Reputation Level)ChiefWigs1982 User rank is Major (30000 - 40000 Reputation Level)ChiefWigs1982 User rank is Major (30000 - 40000 Reputation Level)ChiefWigs1982 User rank is Major (30000 - 40000 Reputation Level)ChiefWigs1982 User rank is Major (30000 - 40000 Reputation Level)ChiefWigs1982 User rank is Major (30000 - 40000 Reputation Level)ChiefWigs1982 User rank is Major (30000 - 40000 Reputation Level)ChiefWigs1982 User rank is Major (30000 - 40000 Reputation Level)  Folding Points: 50746 Folding Title: Beginner FolderFolding Points: 50746 Folding Title: Beginner FolderFolding Points: 50746 Folding Title: Beginner Folder
Time spent in forums: 1 Month 1 Week 3 Days 8 h 42 m 5 sec
Reputation Power: 307
Facebook
Code:
window.opener.document.forms["form"].name1.value = '[resident name]';
window.opener.document.form["form"].N1.value = '[RN]';

Is that just a typo from when you copy/pasted the code?

I changed them all to "forms["form"]" and it worked fine...

Last edited by ChiefWigs1982 : July 2nd, 2008 at 02:31 PM.

Reply With Quote
  #6  
Old July 2nd, 2008, 02:38 PM
cooperljrh cooperljrh is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2006
Location: Jacksonville
Posts: 282 cooperljrh User rank is Sergeant (500 - 2000 Reputation Level)cooperljrh User rank is Sergeant (500 - 2000 Reputation Level)cooperljrh User rank is Sergeant (500 - 2000 Reputation Level)cooperljrh User rank is Sergeant (500 - 2000 Reputation Level)cooperljrh User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 2 Days 1 h 34 m 51 sec
Reputation Power: 9
Send a message via AIM to cooperljrh Send a message via Yahoo to cooperljrh
Quote:
Originally Posted by ChiefWigs1982
Code:
window.opener.document.forms["form"].name1.value = '[resident name]';
window.opener.document.form["form"].N1.value = '[RN]';

Is that just a typo from when you copy/pasted the code?


indeed

i tried both 'document.form["form"].field' and 'document.forms["form"].field' -- neither worked.

should i change the form name on the parent from name="form"? (does the fact that i'm using an html tag as the name impact the functions integrity?)

well...i tried that and it still doesnt work.

should it be form["(form name)"] or forms["(form name)"]

do i need to add or specific the document name? similar to how i am specifying the form?

or maybe the double == signs?

i feel like the thing i am missing is SOOOO simple...and thats what is so frustrating.

Reply With Quote
  #7  
Old July 2nd, 2008, 02:48 PM
cooperljrh cooperljrh is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2006
Location: Jacksonville
Posts: 282 cooperljrh User rank is Sergeant (500 - 2000 Reputation Level)cooperljrh User rank is Sergeant (500 - 2000 Reputation Level)cooperljrh User rank is Sergeant (500 - 2000 Reputation Level)cooperljrh User rank is Sergeant (500 - 2000 Reputation Level)cooperljrh User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 2 Days 1 h 34 m 51 sec
Reputation Power: 9
Send a message via AIM to cooperljrh Send a message via Yahoo to cooperljrh
ive been googling...

ive tried this:
Code:
opener.document.forms['submitForm'].elements['name1'].value = 'name';


and it doesnt work either...

am i executing the function correctly?
Code:
<input type="button" value="Import Information" onClick="setMasterControl();">


or does it need to be:
Code:
<input type="button" value="Import Information" onClick="javascript:setMasterControl();">

Reply With Quote
  #8  
Old July 2nd, 2008, 05:39 PM
ChiefWigs1982's Avatar
ChiefWigs1982 ChiefWigs1982 is offline
Cunning Linguist
ASP Free Loyal (3000 - 3499 posts)
 
Join Date: Mar 2005
Location: I used to live at home, now I stay at the house
Posts: 3,385 ChiefWigs1982 User rank is Major (30000 - 40000 Reputation Level)ChiefWigs1982 User rank is Major (30000 - 40000 Reputation Level)ChiefWigs1982 User rank is Major (30000 - 40000 Reputation Level)ChiefWigs1982 User rank is Major (30000 - 40000 Reputation Level)ChiefWigs1982 User rank is Major (30000 - 40000 Reputation Level)ChiefWigs1982 User rank is Major (30000 - 40000 Reputation Level)ChiefWigs1982 User rank is Major (30000 - 40000 Reputation Level)ChiefWigs1982 User rank is Major (30000 - 40000 Reputation Level)ChiefWigs1982 User rank is Major (30000 - 40000 Reputation Level)ChiefWigs1982 User rank is Major (30000 - 40000 Reputation Level)  Folding Points: 50746 Folding Title: Beginner FolderFolding Points: 50746 Folding Title: Beginner FolderFolding Points: 50746 Folding Title: Beginner Folder
Time spent in forums: 1 Month 1 Week 3 Days 8 h 42 m 5 sec
Reputation Power: 307
Facebook
I don't know what to tell you - you must have some other script
or something interfering. I copied the code as you have it in this
thread and ran it with the correction I pointed out in my previous
post, and it ran exactly as I expected it to...

Reply With Quote
  #9  
Old July 3rd, 2008, 10:19 AM
cooperljrh cooperljrh is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2006
Location: Jacksonville
Posts: 282 cooperljrh User rank is Sergeant (500 - 2000 Reputation Level)cooperljrh User rank is Sergeant (500 - 2000 Reputation Level)cooperljrh User rank is Sergeant (500 - 2000 Reputation Level)cooperljrh User rank is Sergeant (500 - 2000 Reputation Level)cooperljrh User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 2 Days 1 h 34 m 51 sec
Reputation Power: 9
Send a message via AIM to cooperljrh Send a message via Yahoo to cooperljrh
Quote:
Originally Posted by ChiefWigs1982
I don't know what to tell you - you must have some other script
or something interfering. I copied the code as you have it in this
thread and ran it with the correction I pointed out in my previous
post, and it ran exactly as I expected it to...


hmm..well thanks for the help

i appreciate the attempt

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingHTML, JavaScript And CSS Help > Problem with populating opener fields from pop up


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump