|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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! |
|
#2
|
||||
|
||||
|
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).
|
|
#3
|
||||
|
||||
|
Quote:
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 Why are you taking the variable "strInput" into the function?
__________________
Support requests via PM will be ignored! |
|
#4
|
|||
|
|||
|
Quote:
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>
|
|
#5
|
||||
|
||||
|
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. |
|
#6
|
|||
|
|||
|
Quote:
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. |
|
#7
|
|||
|
|||
|
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();"> |
|
#8
|
||||
|
||||
|
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... ![]() |
|
#9
|
|||
|
|||
|
Quote:
hmm..well thanks for the help i appreciate the attempt ![]() |
![]() |
| Viewing: ASP Free Forums > Programming > HTML, JavaScript And CSS Help > Problem with populating opener fields from pop up |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|