Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Obtaining checkbox value dynamically

Status
Not open for further replies.

DariceLR

MIS
Jun 20, 2001
27
0
0
US
Ok... Here's the code... I feel like I'm almost there but I'm missing a piece and I don't know Javascript well enough to know if what I want to do is even feasible.
-------------------------------------------------
<script language="javascript">
function SubmitSelectedToEngine(form)
{
var totalPMMTIDs = parseInt(form.count.value);
var PMMTIDList = "";

for (a=1; a < totalPMMTIDs ; a++) // get PMMTID for each item checked
{
name ="checkbox" + a;
selectedPMMTID = <b>VALUE OF CHECKBOX</b>;

if (selectedPMMTID != "")
{
PMMTIDList = PMMTIDList & "'" & name & "'_"
}
}
// update table to reflect new assignment
if (PMMTIDList != "")
{
//removes extra underscore at end
PMMTIDList = PMMTIDList.substring(0, PMMTIDList.length - 1);
return(false);
}
else
{
alert("You must select at least one request, Darice.");
return (false);
}
</script>

<HTML>
<FORM NAME=frmTable method=POST....>
...
<% If Not rstRequests.EOF Then
n=1
While Not rstRequests.EOF
<!-- Check Box -------------->
<INPUT TYPE=checkbox name="checkbox<%=n%>" value=<%=rstRequests("PMMTID")%>>
... (other data shown)
n=n+1
Wend
Response.Write ("<INPUT NAME='count' TYPE='hidden' VALUE=" & n & ">")

<INPUT TYPE=SUBMIT VALUE="SUBMIT SELECTED" onclick="return(SubmitSelectedToEngine(this.form));" >

</FORM>


-----------------------------------------------
Basically I output all the records with a check box on them. The button should get the value for each checkbox that is selected and create a string of the values. (I'm planning on passing this on to another page that will separate the string up and create .xmls based on it.)




****************
DariceLR
:-{} :-V
****************
 

There are several problems with the code that immediately stand out:

You are missing quotes around some of your strings:

Code:
selectedPMMTID = <b>VALUE OF CHECKBOX</b>;

which should be something like:
Code:
selectedPMMTID = '<b>VALUE OF CHECKBOX</b>';

You are using VBScript in a JavaScript code block:

Code:
PMMTIDList = PMMTIDList & "'" & name & "'_"

which should be something like:
Code:
PMMTIDList += "'" + name + "'_";

Hope this helps,
Dan

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top