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

Pop up windows...

Status
Not open for further replies.

mkiv

MIS
Jan 6, 2003
14
US
I have a page that has a text box that contains a part number. I have to validate that part number against a datasource (which works great), but I was asked if I could allow the user to type a leading portion of a part number, and if when they click on a search button, show (in a popup window?) a list of all parts that "begin" with that string. Then let them select one of those parts, and pass that back to the original text box and close the pop-up window. Here is what I have put together. The javascript im using doesnt seem to be working correctly. Any suggestions? Thanks =)


<cfquery name=&quot;myPart&quot; datasource=&quot;mysxe&quot;>
SELECT prod
FROM pub.icsp where cono = 1 and prod like '#URL.pn#%'
<!--- WHERE EmpLogin='#form.UserID#' AND EmpPasswd='#form.UserPasswd#' --->
</cfquery>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;>
<script language=&quot;JavaScript&quot;>
function returnValue(){
top.opener.document.search.partnumber.value = document.found.chosen.options[document.found.chosen.selectedIndex].value
this.close();
}
</script>
</head>

<body>
<form name=&quot;DBMApprove&quot;>
<select name=&quot;chosen&quot; onchange=&quot;returnValue()&quot;>
<cfoutput query=&quot;myPart&quot;>
<option value=&quot;#prod#&quot;>#prod#</option>
</cfoutput>
</form>

</body>
</html>

 
mkiv,

Is the reference to the parent form field correct? Did you try a hard-coded value (instead of the selected value from the select box) to see if it would populate the parent form?


Once you've determined that your reference is correct,
Try using a two-step process to get the value of the chosen item:

var selected = document.found.chosen.selectedIndex[document.found.chosen.selectedIndex].value

var selectedvalue = document.found.chosen.options[selected].value


 
Still seem to be having some issues. After I select the part number on the pop-up I have a runtime error on 'document.found.chosen'- Any ideas? Thanks

<cfquery name=&quot;myPart&quot; datasource=&quot;mysxe&quot;>
SELECT prod
FROM pub.icsp where cono = 1 and prod like '#URL.pn#%'
<!--- WHERE EmpLogin='#form.UserID#' AND EmpPasswd='#form.UserPasswd#' --->
</cfquery>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;>
<script language=&quot;JavaScript&quot;>
function returnValue(){
var selected = document.found.chosen.selectedIndex[document.found.chosen.selectedIndex].value
var selectedvalue = document.found.chosen.options[selected].value
this.close();
}
</script>
</head>

<body>
<form name=&quot;DBMApprove&quot;>
<select name=&quot;chosen&quot; onchange=&quot;returnValue()&quot;>
<cfoutput query=&quot;myPart&quot;>
<option value=&quot;#prod#&quot;>#prod#</option>
</cfoutput>
</form>

</body>
</html>
 
Oops, cut-and-paste mishaps.

var selected = document.found.chosen.selectedIndex
var selectedvalue = document.found.chosen.options[selected].value;
alert(selectedvalue); \\to test

HTH,
PH
 
I seem to be having the same problem. Any other ideas?

<cfquery name=&quot;myPart&quot; datasource=&quot;mysxe&quot;>
SELECT prod
FROM pub.icsp where cono = 1 and prod like '#URL.pn#%'
<!--- WHERE EmpLogin='#form.UserID#' AND EmpPasswd='#form.UserPasswd#' --->
</cfquery>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;>
<script language=&quot;JavaScript&quot;>
function returnValue(){
var selected = document.found.chosen.selectedIndex
var selectedvalue = document.found.chosen.options[selected].value;
alert(selectedvalue);
this.close();
}
</script>
</head>

<body>
<form name=&quot;DBMApprove&quot;>
<select name=&quot;chosen&quot; onchange=&quot;returnValue()&quot;>
<cfoutput query=&quot;myPart&quot;>
<option value=&quot;#prod#&quot;>#prod#</option>
</cfoutput>
</form>

</body>
</html>

Thanks for all the help....

Ryan
 
mkiv,

(sorry for the delay) Does the document have a form named &quot;found&quot;? Does the form have a select box named &quot;chosen&quot;? If so, I fail to see why this code wouldn't work.

Replace my alert box with

opener.document.search.partnumber.value = selectedvalue

(Notice I got rid of &quot;top&quot;. &quot;top&quot; doesn't have an opener; this page does.)

Speaking of, can you retrieve a value with

alert(top.opener.document.search.partnumber.value);

HTH,
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top