PDA

View Full Version : Submit form from Script


ScottInTexas
07-12-2003, 04:37 PM
This really has two parts, ASP and Javascript. I have retireved the names of the tables in a database and I want to set the value of a hidden field on a form with one of the names and then submit the form to an asp that opens the table and displays the fields and values.

My ASP builds a menu of tbalnames and inserts the onClick during the contruction. The form is predefined with a hidden field on the page. On click should assign a value to the hidden field and then post the form. Here's the code.

javascript function

function GetTable(which){
var thiselement=document.getElementById("tblnam");
alert(thiselement.value); /* This shows me */
thiselement.value=which.innerText;
document.all.tbltree.submit;
}

This is the resulting page after the previous function.

<form id="tbltree" action="GetData.asp" method="Post">
<Div id="DBStruct" >
<table id="tblList"><input type="hidden" id="tblnam" value="me" />
<tr><td class="tblName" onClick="GetTable(this)">

etc, etc.



I thought that by assigning a value to the input and then calling the submit method the form would post. Is there a way to do this?

Roy Sinclair
07-14-2003, 04:31 PM
You are trying to get the "value" of a table cell. Table cells don't have values, they have text or html contents; it's form fields which have values.


Your html is also not legal, you've defined a form field inside a table (your hidden field) but it's not inside a <td></td> or <th></th> pair.