Forum Moderators: open

Message Too Old, No Replies

Help needed improving this passback script

         

nevdev

12:26 pm on Jul 20, 2005 (gmt 0)

10+ Year Member



I have a form which asks the user to select a colour, amongst other things. Since there are quite a range of colours, I thought it would be nice if the user could see them all in a popup window, click on one to pick it, and have some javascript return to the page and do the relevant form-filling for them.

Using a script fragment I found, I came up with the following:

Now my questions are:

How can I return the selected colour-image back to the "main page", as well as the selected value, so the selected colour-image can be shown as a reminder, somewhere near the form?

There are some more aspects of the form that I need help with (on the page), but just getting the image to return as well as the value would be a great start!

Thanks in advance!

[edited by: jatar_k at 8:39 pm (utc) on July 20, 2005]
[edit reason] no urls thanks [/edit]

nevdev

12:50 pm on Jul 20, 2005 (gmt 0)

10+ Year Member



Perhaps I should include the main part of the code:

<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
<script>
var _v = "<html><head><"+"script>";
_v += "function passBack(_a){opener.catchIt(_a);self.close();}";
_v += "<"+"/script></head><body>";
_v += "<a href=\"#\" onclick=passBack('123T')><img src=\"images/colour1.jpg\" alt=\"blonde\" height=\"100\" width=\"85\" border=\"0\"></a><br>";
_v += "<a href=\"#\" onclick=passBack('637T')><img src=\"images/colour2.jpg\" alt=\"brunette\" height=\"100\" width=\"85\" border=\"0\"></a><br>";
_v += "</body></html>";
var newWin=null;
function doIt()
{
newWin=window.open("","","width=500,height=300,top=100,left=100");
newWin.document.open();
newWin.document.write(_v);
newWin.document.close();
}
function catchIt(_z)
{
if (document.all)
{
document.all.one.innerHTML=_z;
document.all.two.innerHTML="Choose again?";
}
document.justforshow.data.value=_z; /* just for show */
}
</script>
<link href="styles/style01.css" type="text/css" rel="stylesheet" media="screen">
<title>Popup Selection Passing Back To Form</title>
</head>

<body>
<table class="maintext" width="90%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><br>
<br>
<span class="TextEmphasis">Popup Selection Passing Back To Form</span><br>
<br>
<br>
<br>
<table class="maintext" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><a id="two" onclick="doIt()" href="#">Choose colour</a></td>
<td align="center">
<div align="center">
<img src="images/singtranspixel.gif" alt="" height="15" width="50" border="0"></div>
</td>
<td><a id="one">COLOUR</a></td>
</tr>
</table>
<br>
<form name="justforshow">
Selected Value: <input type="text" name="data" value="(choose colour to display)" readonly>
</form>
</td>
</tr>
<tr>
<td><br>
</td>
</tr>
</table>
<p></p>
</body>
</html>

rocknbil

7:06 pm on Jul 20, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Search this site or google for window.opener. The window.opener is the page and form your pop-up is generated from. You will be setting form values by coding "window.opener.formname.formfield.value=whatever".

You can make hidden fields or non-editable text fields in the form and when you finalize the window it sets the values for them.

nevdev

8:35 pm on Jul 20, 2005 (gmt 0)

10+ Year Member



That must be wonderful: I don't understand it at all.
-Moliere

I hope I can find some good examples! Thanks for your help!

nevdev

12:15 pm on Jul 21, 2005 (gmt 0)

10+ Year Member



Does anyone know of a script anywhere that can do this, or which can be modified to do it?

rocknbil

4:16 pm on Jul 21, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



One WW example [webmasterworld.com]

Another [webmasterworld.com]

Full Google results from WW [google.com]

(Use the advanced search on Google, select only this doamin, enter webmasterworld.com)

nevdev

4:46 pm on Jul 21, 2005 (gmt 0)

10+ Year Member



many thanks for your suggestions