PDA

View Full Version : passing form variable back to main form


chrome orange
11-30-2004, 02:19 PM
afternoon all! first post :)

right I have a large form for creating a query to search a database. One of the fields to search on is postcode. I am using a text box to enter the 2 byte postcodes (AB,ST,NN.... etc), all is fine with this.

BUT

The client wants a load of tick boxes incase the operator doesn't have a list of post codes available.

I get all the postcodes from the database (there are 125 postcode areas in the uk) and this all works fine.

What i want to do is have a link next to the text box detailed above to open a window and display all the 125 text boxes, then i tick the required boxes and click 'submit' this will then format the array of ticked boxes AND put the list in to my text field on the original page.


right I can do all of it just not together.

<script language="JavaScript">
function restart(){
document.eroll_form.post2.value = post2;
mywindow.close();
}
</script>
<form action="" method="post" name="eroll_form" id="eroll_form">
<input type="text" name="post2" value="">
POST 2 <a href="javascript:showPost2()">Show Post 2</a>
</form>

will open a new window


<script language="JavaScript">
function generateArray(){
<%
post_code = ""
post_code = Split(Request.form("postcode2"),",")
For intX = 0 to UBound(post_code)
post_code(intx) ="'"&trim(post_code(intx))&"'"
Next
postcode_array = Join(post_code,",")
%>
opener.post2 = postcode_array;
opener.restart();
self.close();
}
</script>



<html>
<head>
<title>post2</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<form name="post_form">
<table width="90%" border="0" cellspacing="1" cellpadding="1">
<tr>
<td>AB</td>
<td><input name="postcode2" type="checkbox" id="ab" value="ab"></td>
</tr>
<tr>
<td>ST</td>
<td><input name="postcode2" type="checkbox" id="ST" value="ST"></td>
</tr>
<tr>
<td>E</td>
<td><input name="postcode2" type="checkbox" id="E" value="E"></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td><input type="button" value="Submit" onClick="javascript:generateArray();"></td>
<td>&nbsp;</td>
</tr>
</table>
</form>
</body>
</html>


is my popup page, i'm not using the database to get my postcodes, just a sample of 3.



<%
post_code = ""
post_code = Split(Request.form("postcode2"),",")
For intX = 0 to UBound(post_code)
post_code(intx) ="'"&trim(post_code(intx))&"'"
Next
postcode_array = Join(post_code,",")
%>


is the part from my original asp page which gathered all the ticked boxes and formatted them into an array, this works in its original form but not when i put it into the script (i have removed the <% %> tags )

what i need to do is rewrite that bit so that it does the reformatting and thats where i'm stuck :)

help!


TIA

Andy