View Full Version : Select Box Script not working with forms

01-04-2007, 04:30 PM
I am using a javascript given to be by a helpful member (vwphillips). The code works great, but I am not getting the data tranferred into my forms. So from the users standpoint everything works great but on my side when I receive the completed form I don't get the data they selected. I am using FrontPage and the rest of the form is working fine. The page with an example of this problem is www.affordyourbills.com/example.htm (http://www.affordyourbills.com/example.htm)
When the user selects their "home value" the other options are generated. But once I get the completed form the only values that are missing are options generated by the code. If the user chooses not the select the other options, then the "Select One" is transmitted to me.
Here is the code that I originally began with... the code with options is too large to post, but is on the previously mentioned link.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"


<script language="JavaScript" type="text/javascript">
var Ary1=[];
Ary1[1]=['Topic 1','Topic 2'];
Ary1[2]=['Topic 3','Topic 4'];

function Populate(obj,ary,sela,selb){
var args=Populate.arguments;
var index=args[0].selectedIndex;
if (index<1){ return; }
for (var zxc0=2;zxc0<args.length;zxc0++){
var sel=document.getElementById(args[zxc0]);
sel.options[0]=new Option('Select','',true,true);
for (var zxc1=0;zxc1<ary[index].length;zxc1++){
sel.options[zxc1+1]=new Option(ary[index][zxc1],'',true,true);


<select onclick="Populate(this,Ary1,'Sel2','Sel3');" >
<option >Select</option>
<option >List 1</option>
<option >List 2</option>
<select id="Sel2">
<option >EMPTY</option>
<select id="Sel3">
<option >EMPTY</option>


Thank you for any help!!!

01-04-2007, 04:37 PM
Select elements must have a name attribute to be passed on via a form to most back-end things, IIRC.
Try giving them names.
A simple test here confirms that the value is not passed in the URL via GET if you remove the name attribute. I assume POST is the same.

<select id="sel_1" name="sel_1">
<option value='1'>1</option>
<option value='1'>2</option>
<option value='1'>3</option>
<option value='1'>4</option>
<input type="submit">

01-04-2007, 05:01 PM
Thanks for the response. In my actual page I believe I have each entry named, but I may not be interpretting this correctly. Here is an example of the code

<select id="Sel2" name="D2" size="1" style="width: 165; height: 22">
<option >Select One</option>
I tried changing the name of the field to "Sel2" instead of "D2", but that didn't have any effect.

01-04-2007, 05:44 PM
Ok; change the method of the form to GET, so you see the values in the URL.
Pop in some values and submit it.
Do you see the values that you selected in the URL? If so, the problem is the back-end Frontpage stuff. If not, it's something in the front-end script or HTML.

01-04-2007, 07:00 PM
I think it is FrontPage. When I change the method to GET, it immediately changes it back to POST when I save changes. It looks like I may have to pursue another method to get these forms to submit all the information correctly. Thank you for your help!