codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  help - problem inserting string into parent window textbox  blakeph at 04:59 on Wednesday, June 29, 2005
 

hi guys! i have a form that will insert the variable from child to parent window textbox, after submitting the names of the employees from the child window listbox, the variables contains the email address of the employees, it does insert into the textbox but in the wrong way.

for example, if i submit "dave", the email address of laura will be inserted into the parent window textbox, instead of dave, this happens when you filter the names, but if you didnt filter the names, the variables will be inserted in the proper way.

any help would be highly appreciated.

below is my parent window:
<HTML>
<HEAD>

<SCRIPT LANGUAGE="JavaScript">

<!--
function NewOption(){
sel=document.getElementById('PICKED');
sel.options[sel.options.length]=new Option(arguments[0],arguments[1],true,true);

//alert("ID = "+arguments[0][0]+"\nName = "+arguments[0][1]+"\nEmail = "+arguments[0][2]);
}
// pop-up window
function PopUp(PopUpUrl){
var ScreenWidth=window.screen.width;
var ScreenHeight=window.screen.height;
var movefromedge=0;
placementx=(ScreenWidth/2)-((310)/500);
placementy=(ScreenHeight/2)-((240+10)/6);
WinPop=window.open(PopUpUrl,"","width=500,height=290,toolbar=0,location=0,directories=0,status=0,scrollbars=0,menubar=0,resizable=0,left="+placementx+",top="+placementy+",screenX="+placementx+",screenY="+placementy+",");
}
// -->
</SCRIPT>

</HEAD>
<BODY BGCOLOR="#E0EOFF" style="text-align: center">
<table border="1" width="24%" id="table1">
<tr>
<td>
<form name="form">
<p align="center">E-mail Address:
<input type="text" name="emailbox" size="22"></p>
</form>
</td>
</tr>
<tr>
<td>
<FONT FACE="sans-serif">
<div align="center">
<TABLE CELLPADDING="7" CELLSPACING="0" BORDER = "3" WIDTH="203" bgcolor="#FFFFFF" id="table3">
<TR>
<TD align="center">
</FONT>
<FONT FACE="Verdana">
<TABLE WIDTH="40%" CELLPADDING="0" CELLSPACING="0" BORDER="0" id="table4">
<TR>
<TD>
<FONT FACE="Verdana">
<TABLE WIDTH="40%" CELLPADDING="0" CELLSPACING="0" BORDER="0" id="table5">
<TR>
<TD WIDTH="40%" align="center">
<FONT FACE="Verdana"><p align="left">
<SELECT NAME="PICKED" SIZE="9" MULTIPLE style="width: 240; height: 150">
</SELECT></FONT></TD>
</TR>
</TABLE>
</font>
<p align="center"><FONT FACE="sans-serif"><input type="button" name="button" value="child window" onclick="PopUp('/forum/child.htm')"></FONT></TD>
</CENTER>
</FORM>
</div>
</td>
</tr>
</table>
</BODY>
</HTML>


and below is my child window:
<HTML>
<HEAD>
<TITLE>Address List</TITLE>

<!-- Load the javascript code -->
<script language="javascript">

/*==================================================*
$Id: filterlist.js,v 1.3 2003/10/08 17:13:49 pat Exp $
Copyright 2003 Patrick Fitzgerald
http://www.barelyfitz.com/webdesign/articles/filterlist/
*==================================================*/

function filterlist(selectobj) {

//==================================================
// PARAMETERS
//==================================================

// HTML SELECT object
// For example, set this to document.myform.myselect
this.selectobj = selectobj;

// Flags for regexp matching.
// "i" = ignore case; "" = do not ignore case
// You can use the set_ignore_case() method to set this
this.flags = 'i';

// Which parts of the select list do you want to match?
this.match_text = true;
this.match_value = false;

// You can set the hook variable to a function that
// is called whenever the select list is filtered.
// For example:
// myfilterlist.hook = function() { }

// Flag for debug alerts
// Set to true if you are having problems.
this.show_debug = false;

//==================================================
// METHODS
//==================================================

//--------------------------------------------------
this.init = function() {
// This method initilizes the object.
// This method is called automatically when you create the object.
// You should call this again if you alter the selectobj parameter.

if (!this.selectobj) return this.debug('selectobj not defined');
if (!this.selectobj.options) return this.debug('selectobj.options not defined');

// Make a copy of the select list options array
this.optionscopy = new Array();
if (this.selectobj && this.selectobj.options) {
for (var i=0; i < this.selectobj.options.length; i++) {

// Create a new Option
this.optionscopy = new Option();

// Set the text for the Option
this.optionscopy.text = selectobj.options.text;

// Set the value for the Option.
// If the value wasn't set in the original select list,
// then use the text.
if (selectobj.options.value) {
this.optionscopy.value = selectobj.options.value;
} else {
this.optionscopy.value = selectobj.options.text;
}

}
}
}

//--------------------------------------------------
this.reset = function() {
// This method resets the select list to the original state.
// It also unselects all of the options.

this.set('');
}


//--------------------------------------------------
this.set = function(pattern) {
// This method removes all of the options from the select list,
// then adds only the options that match the pattern regexp.
// It also unselects all of the options.

var loop=0, index=0, regexp, e;

if (!this.selectobj) return this.debug('selectobj not defined');
if (!this.selectobj.options) return this.debug('selectobj.options not defined');

// Clear the select list so nothing is displayed
this.selectobj.options.length = 0;

// Set up the regular expression.
// If there is an error in the regexp,
// then return without selecting any items.
try {

// Initialize the regexp
regexp = new RegExp(pattern, this.flags);

} catch(e) {

// There was an error creating the regexp.

// If the user specified a function hook,
// call it now, then return
if (typeof this.hook == 'function') {
this.hook();
}

return;
}

// Loop through the entire select list and
// add the matching items to the select list
for (loop=0; loop < this.optionscopy.length; loop++) {

// This is the option that we're currently testing
var option = this.optionscopy[loop];

// Check if we have a match
if ((this.match_text && regexp.test(option.text)) ||
(this.match_value && regexp.test(option.value))) {

// We have a match, so add this option to the select list
// and increment the index

this.selectobj.options[index++] =
new Option(option.text, option.value, false);

}
}

// If the user specified a function hook,
// call it now
if (typeof this.hook == 'function') {
this.hook();
}

}


//--------------------------------------------------
this.set_ignore_case = function(value) {
// This method sets the regexp flags.
// If value is true, sets the flags to "i".
// If value is false, sets the flags to "".

if (value) {
this.flags = 'i';
} else {
this.flags = '';
}
}


//--------------------------------------------------
this.debug = function(msg) {
if (this.show_debug) {
alert('FilterList: ' + msg);
}
}


//==================================================
// Initialize the object
//==================================================
this.init();

}

function SendInfo(){
var employees = [

[1, "dave", "dave@xyz.com"],
[2, "john", "john@xyz.com"],
[3, "peter", "peter@xyz.com"],
[4, "mathew", "mathew@xyz.com"],
[5, "laura", "laura@xyz.com"],
[6, "cynthia", "cynthia@xyz.com"],
[7, "amanda", "amanda@xyz.com"],
[8, "josephine", "josephine@xyz.com"],
[9, "david", "david@xyz.com"],
[10, "blake", "blake@xyz.com"],

];

var Val = document.usersform.usersselect.options[document.usersform.usersselect.selectedIndex].value;
var txt = document.usersform.usersselect.options[document.usersform.usersselect.selectedIndex].text;
var sel = window.opener.NewOption(txt, Val);
window.opener.document.form.emailbox.value = employees[document.usersform.usersselect.selectedIndex][2];

}
</SCRIPT>

</HEAD>
<BODY>
<FORM NAME="usersform">
<div align="center">
<table class=rowtable cellpadding="10" cellspacing="1" border="0" width="470">
<TR class=row1 valign=top>
<TH>Users</TH>
<TH>Filter</TH>
</TR>
<TR VALIGN="top">
<TD class=row1 STYLE="width:175px">
<DIV ID="filtertext"> </DIV>
<SELECT SIZE=6 NAME="usersselect" STYLE="width:173; height:96">
<option value="1">dave</option>
<option value="2">john</option>
<option value="3">peter</option>
<option value="4">mathew</option>
<option value="5">laura</option>
<option value="6">cynthia</option>
<option value="7">amanda</option>
<option value="8">josephine</option>
<option value="9">david</option>
<option value="10">blake</option>
</SELECT></p>
<BR>
<INPUT TYPE=submit VALUE="Enter" onclick="SendInfo()">
<TD class=row2>

<SCRIPT TYPE="text/javascript">
<!--
var filter = new filterlist(document.usersform.usersselect);

filter.hook = function() {

if (this.selectobj.options.length) {
this.selectobj.options[0].selected = true;
}

if (document.getElementById) {
var id = document.getElementById("filtertext");
if (typeof id.innerHTML != 'undefined') {
if (this.selectobj.length == this.optionscopy.length) {
id.innerHTML = " ";
} else {
id.innerHTML = "Showing " +
this.selectobj.length + " of " +
this.optionscopy.length + " records";

}
}
}
}

function dofilter(regexp) {
document.usersform.regexp.value = regexp;
filter.set(regexp);
}
//-->
</SCRIPT>

<P STYLE="width:200px">
Show users:
<A HREF="javascript:dofilter('')" TITLE="Show all items">All</A><BR>
<A HREF="javascript:dofilter('^A')" TITLE="Show items starting with A">A</A>
<A HREF="javascript:dofilter('^B')" TITLE="Show items starting with B">B</A>
<A HREF="javascript:dofilter('^C')" TITLE="Show items starting with C">C</A>
<A HREF="javascript:dofilter('^D')" TITLE="Show items starting with D">D</A>
<A HREF="javascript:dofilter('^E')" TITLE="Show items starting with E">E</A>
<A HREF="javascript:dofilter('^F')" TITLE="Show items starting with F">F</A>
<A HREF="javascript:dofilter('^G')" TITLE="Show items starting with G">G</A>
<A HREF="javascript:dofilter('^H')" TITLE="Show items starting with H">H</A>
<A HREF="javascript:dofilter('^I')" TITLE="Show items starting with I">I</A>
<A HREF="javascript:dofilter('^J')" TITLE="Show items starting with J">J</A>
<A HREF="javascript:dofilter('^K')" TITLE="Show items starting with K">K</A>
<A HREF="javascript:dofilter('^L')" TITLE="Show items starting with L">L</A>
<A HREF="javascript:dofilter('^M')" TITLE="Show items starting with M">M</A>
<A HREF="javascript:dofilter('^N')" TITLE="Show items starting with N">N</A>
<A HREF="javascript:dofilter('^O')" TITLE="Show items starting with O">O</A>
<A HREF="javascript:dofilter('^P')" TITLE="Show items starting with P">P</A>
<A HREF="javascript:dofilter('^Q')" TITLE="Show items starting with Q">Q</A>
<A HREF="javascript:dofilter('^R')" TITLE="Show items starting with R">R</A>
<A HREF="javascript:dofilter('^S')" TITLE="Show items starting with S">S</A>
<A HREF="javascript:dofilter('^T')" TITLE="Show items starting with T">T</A>
<A HREF="javascript:dofilter('^U')" TITLE="Show items starting with U">U</A>
<A HREF="javascript:dofilter('^V')" TITLE="Show items starting with V">V</A>
<A HREF="javascript:dofilter('^W')" TITLE="Show items starting with W">W</A>
<A HREF="javascript:dofilter('^X')" TITLE="Show items starting with X">X</A>
<A HREF="javascript:dofilter('^Y')" TITLE="Show items starting with Y">Y</A>
<A HREF="javascript:dofilter('^Z')" TITLE="Show items starting with Z">Z</A>

<P>Filter by regular expression:<BR>
<INPUT NAME=regexp onKeyUp="filter.set(this.form.regexp.value)">
<INPUT TYPE=button onClick="filter.set(this.form.regexp.value)" value="Filter">
<INPUT TYPE=button onClick="filter.reset();this.form.regexp.value=''" value="Clear">

<P>
<INPUT TYPE=checkbox NAME="toLowerCase"onClick="filter.set_ignore_case(!this.checked);filter.set(this.form.regexp.value);">
Case-sensitive filtering

</TD>
</TR>
</TABLE>

</div>

</FORM>
</BODY>
</HTML>








CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  Re: Running a Javascript from VBA.
•  Position relative div is larger than absolute div
•  using a boolean class to stop duplicates in an array
•  Reading an object through Reflection
•  Re: Encryption problem! Help!
•  segmentation fault...please, I need help!
•  Re: MySQL Client
•  Re: PERL :: BFormMail.pl :: Forbidden Error :: ( - Idiot needs help. - )
•  Re: RegExp


Recent Articles
Communicating with the Database (Using ADO)
MagicGrid
Simple Thumbnail Browsing Solution
Type Anywhere
A Better Moustrap: FmtDate to replace FormatDateTime
ASP.NET Forum Source Code
Internal Search Engine
Javascript Growing Window
Simple date validation
Search engine friendly URLs using ASP.NET (C#.NET)


Site Survey
Help us serve you better. Take a five minute survey. Click here!

© Copyright codetoad.com 2001-2005