Input value will not change using javascript
<p>I'm having a hard time figuring out how to change values of some input values using javascript.  Can you take a look at my code and tell me why this isn't working?</p>

<p>Here is the c# portion of the page:  </p>

<pre><code>   protected void Page_Init(object sender, EventArgs e)
    {
        if (!Page.IsPostBack) {
        String date = DateTime.Today.AddDays(1).ToString("yyyyMMdd");

        String myConnectionString = "Driver={Pervasive ODBC Client Interface};servername=192.168.1.2;dbq=@dbname;";
        String commandString = "valid SELECT statement";
        OdbcConnection myConnection = new OdbcConnection();
        myConnection.ConnectionString = myConnectionString;
        OdbcDataReader reader2;
        OdbcDataReader reader3;
        OdbcCommand command = new OdbcCommand(commandString, myConnection);

        try
        {
            myConnection.Open();
            OdbcDataReader reader = command.ExecuteReader();

            delList.Controls.Clear();

            Table tbl = new Table();
            tbl.ID = "tbl1";
            tbl.BorderWidth = 1;
            delList.Controls.Add(tbl);

            //add header row
            String[] headers = { "id", "ticket#", "address", "city", "state", "zip", "start time", "end time", "total cube", "route" };
            TableHeaderRow th = new TableHeaderRow();
            TableCell tc;
            for (int i = 0; i &lt; headers.Length; i++)
            {
                tc = new TableCell();
                tc.BorderWidth = 1;
                tc.Text = headers[i];
                th.Cells.Add(tc);
            }
            tbl.Rows.Add(th);

            int fCount = reader.FieldCount;
            int index = 1;
            char[] rem = new char[2] { 'B', 'D' };

            HtmlInputHidden hidden1, hidden2, hidden3;

            while (reader.Read())
            {

                if(reader.GetValue(fCount -1).ToString()[0] == 'D')
                {

                    TableRow tr = new TableRow();
                    tc = new TableCell();
                    tc.Text = index.ToString();
                    tc.BorderWidth = 1;
                    tr.Cells.Add(tc);
                    //create hidden field
                    hidden1 = new HtmlInputHidden();
                    hidden2 = new HtmlInputHidden();
                    hidden1.ID = "tick" + index;
                    hidden2.ID = "rte" + index;
                    hidden1.Value = reader.GetValue(0).ToString();
                    this.Controls.Add(hidden1);
                    for (int i = 0; i &lt; fCount-1 ; i++)
                    {
                        tc = new TableCell();
                        tc.Text = reader.GetValue(i).ToString();
                        tc.BorderWidth = 1;
                        tr.Cells.Add(tc);
                    }
                    //get cube
                    String getItems = "SELECT so_dtl_item_id, so_dtl_qty_to_ship FROM so_dtl WHERE so_dtl_no='" + reader.GetValue(0) + "';";
                    String getCubes = "SELECT item_cube FROM item WHERE item_id='";
                    command = new OdbcCommand(getItems, myConnection);
                    reader2 = command.ExecuteReader();
                    double cubes = 0;
                    while (reader2.Read())
                    {
                        command = new OdbcCommand(getCubes + reader2.GetValue(0).ToString() + "';", myConnection);
                        reader3 = command.ExecuteReader();
                        double tmp = 0;
                        while (reader3.Read())
                        {
                            tmp = Convert.ToDouble(reader3.GetValue(0));
                        }
                        cubes += tmp * Convert.ToDouble(reader2.GetValue(1));
                        reader3.Close();
                    }                        
                    reader2.Close();
                    tc = new TableCell();
                    tc.BorderWidth = 1;
                    tc.Attributes["name"] = "cubes";
                    tc.Text = cubes.ToString();
                    tr.Cells.Add(tc);

                    //get route
                    tc = new TableCell();
                    tc.BorderWidth = 1;
                    String rteNum = reader.GetValue(fCount - 1).ToString().TrimStart(rem);

                    hidden2.Value = rteNum;
                    this.Controls.Add(hidden2);

                    tc.Text = "&lt;input name=\"route\" id=\"route\" type=\"text\" value="+ rteNum +" onblur=\"refresh()\" /&gt;";
                    tr.Cells.Add(tc);

                    tbl.Rows.Add(tr);
                    index++;
                }
            }

            hidden3 = new HtmlInputHidden();
            hidden3.ID = "total";
            hidden3.Value = index.ToString();
            this.Controls.Add(hidden3);

            reader.Close();
            command.Dispose();
            myConnection.Close();
        }
        catch (OdbcException ex)
        {
            System.Diagnostics.Trace.WriteLine(ex.Message);
        }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button_Click(object sender, EventArgs e)
    {
        HtmlInputHidden hiddenControl = (HtmlInputHidden)FindControl("total");
        try
        {
            int total = Convert.ToInt32(hiddenControl.Value);
            String ticket, route;

            for (int i = 1; i &lt; total; i++)
            {
                hiddenControl = (HtmlInputHidden)FindControl("tick" + i);
                ticket = hiddenControl.Value;

                hiddenControl = (HtmlInputHidden)FindControl("rte" + i);
                route = hiddenControl.Value;

                System.Diagnostics.Trace.WriteLine(ticket + ": " + route);
            }
        }
        catch (FormatException ex)
        {
            Console.WriteLine("Input string is not a sequence of digits.");
            System.Diagnostics.Trace.WriteLine(ex.Message);
        }
        catch (OverflowException ex)
        {
            Console.WriteLine("The number cannot fit in an Int32.");
            System.Diagnostics.Trace.WriteLine(ex.Message);
        }
    }
</code></pre>

<p>And here is the javascript to update the values:</p>

<pre><code>    function update() {
            var tbl = document.getElementById('MainContent_tbl1');
            var rows = tbl.getElementsByTagName('tr');
            var routes = document.getElementsByName("route");
            var mod;
            //make call to c# func to have the database updated
            for (var i = 1; i &lt; rows.length; i++) {
                mod = document.getElementById("rte" + i);
                //for testing
                if (i == 1 || i == 10) {
                    alert("rte" + i + ", " + mod.value);
                }
                //change value
                mod.value = routes[i - 1].value;
                //for testing
                if (i == 1 || i == 10) {
                    alert("rte" + i + ", " + mod.value);
                }
         }
</code></pre>

<p>The alerts display the correct values, but the values themselves are never changed in the source.  All help will be greatly appreciated, Thanks.</p>

<p>I added if (!Page.IsPostBack) to page_init so now the value doesn't change back but it returns as null any reason that may be happening?</p>
