Greetings,

I have a form that uses a child popup form to generate data for some fields on the form. The same popup is used for several fields. The forms use php & javascript.

An example of the field to be filled and the button that activates the popup is as follows:

<input type="text" size="60" name="cover" value="<?echo $cover;?>">
<input style="font-size:12px;color:#000066;font-family:verdana;" type="button" name="B1" value="..." onClick="popup('/test/test.php?field=cover','filechooser','640','480','center','front');">

The name of the field that needs to be filled is passed to the child popup via GET.

The popup asks for user input then generates a value for the "folder" field in the same form. Once the user is satisfied they click the OK button, the popup closes and the little bit of javascript passes the value of the "folder" field back to the appropriate field on the parent form.

$field=$_GET['field'];
<form>
<input type="text" size="60" name="folder" value="<echo $final_input;?>">
<input type="button" value="OK" onclick="window.close()">
<script language="javascript"> 
var myVar = "<echo $final_input;?>"; 
window.opener.input.<?echo $field;?>.value = myVar; 
</script>
</form>

Now, all this actually mostly works quite well... Mostly... The problems occur when the field to be filled is an element of any array. ie

<input type="text" size="60" name="cover[0]" value="<?echo $cover[0];?>">
<input style="font-size:12px;color:#000066;font-family:verdana;" type="button" name="B1" value="..." onClick="popup('/test/test.php?field=cover[0]','filechooser','640','480','center','front');">

The popup loads, but I get the "done with errors" thingy. All the pocessing in the popup goes OK, but the value is not passed back to the parent form.

Any ideas what might be causing this or how to get around it? Or perhaps a better way of doing this?

Any help appreciated.
Thanks
Phil

cover[0] is not a valid name. There are a fixed set of rules which govern what exactly a valid name looks like. Keep it something like cover0 .

When developing, use Firefox so that tracing such errors is a breeze using the Firefox Error Console and Firebug plugin. You would get a much detailed error in contrast to the almost useless 'Object expected' stuff thrown in by IE.

OK, fair enough. But in PHP world cover[0] is OK, and that's the field that I need filled. Depending on user input in a previous form, there may be 1 or many "cover"s. This necessitates an array.

So is there any way to get around this? Doing the whole thing some other way perhaps?

Thanks again
Phil

This article has been dead for over six months. Start a new discussion instead.