matth76
03-15-2006, 04:24 AM
Hi
I have created an ASP page which outputs data from a database displaying contents of a basket. This all works fine. One of the fields that is displayed is the 'quote basket name' which I have displayed in an input text field to allow a user to edit it. Next to each record that is displayed I have put a tickbox that the user must select meaning they want to edit just that record, they then edit the basket name text input field right next to the checkbox. I can return the 'value' of the check box selected which returns the basket id - this works. I have created an array to hold all the text input field values. I now need some way of getting the index or order of the checkbox selected and then linking it to the appropriate index in the array so as to know this is the correct basket name to update. I am having a problem finding out how to get the 'order' or index of the checkbox selected.
I have no problem returning the basket id (which is the 'value' of the checkbox ticked). No problems at all with the basket itself). My only problem is updating the database with the basket name (this is an 'editable' field in the display grid) based on what the user has entered in the field AND which checkbox has been ticked. Each check box holds the basket id (as its value). This I can return no problem - the question is I can't 'link' up the checkbox in any way to the basket name text input field.
Ideally I would want to get the 'ID' or order of the checkbox that was ticked. And then use this index to return the associated index in the array (the array holds all the basket name input field values).
For example if I have 5 records being displayed. The user ticks the third checkbox down. I need a way of knowing that this is the THIRD checkbox. Then with the 'number 3' I can use this to return the item in the array with an index of 2 (as an array always starts at 0, so this would in effect therefore be the third basket name item in the array - and therefore the basket name 'linked' with the third checkbox that was ticked). My problem is I have no idea how to work out that it was the third checkbox ticked.
Is there any way to do this?
How would an onBlur example work?
Please can someone help me with this problem. Thank you very much for any help.
Here is the code that should be run when a user clicks an update 'button' (the input text field and checkbox field is at the bottom of the code):
'-------------------------------
'get the basket name that user has entered and put into array
formbasketname = Request.Form("sel_quotename")
formarray = Split(formbasketname,", ")
for j=0 to Ubound(formarray)
Response.Write "<br>" & formarray(j) 'TEST display contents of array - (this all works)
next 'move to next element in array
Set rsBasket = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT * FROM tvQuoteBasket_GetBasket WHERE user_id = " & userid
rsBasket.Open strSQL, cnnConn, 1, 4
rsBasket.MoveFirst
do
'get the checkbox value selected by the user - this holds the basketid value - (this works)
chkboxvalue = Request.Form("chkbox")(i)
'******NOW NEED TO GET THE BASKET NAME ENTERED BY USER THAT IS ASSOCIATED WITH THE CHECKBOX SELECTED
'******THEREFORE NEED SOME WAY TO GET THE 'ORDER' OF THE CHECKBOXES SELECTED. CURRENTLY 'i' JUST SHOWS THE TOTAL NUMBER OF CHECKBOXES SELECTED
'UPDATE DATABASE CODE GOES HERE (THIS IS NO PROBLEM) BUT NEED CORRECT VALUE OF BASKET NAME TO UPDATE WITH!
rsBasket.MoveNext
i = i + 1
loop until i = (Request.Form("chkbox").Count)
rsBasket.Close
'Code showing the checkbox filed and basket name input field - (this all works)
<INPUT type='checkbox' value='<%= basketid %>' name='chkbox'>
<input type="text" name="sel_quotename" value="<%=quotebasketname%>" maxlength="50" size="50">
'-------------------------------
Thank you for any help.
I have created an ASP page which outputs data from a database displaying contents of a basket. This all works fine. One of the fields that is displayed is the 'quote basket name' which I have displayed in an input text field to allow a user to edit it. Next to each record that is displayed I have put a tickbox that the user must select meaning they want to edit just that record, they then edit the basket name text input field right next to the checkbox. I can return the 'value' of the check box selected which returns the basket id - this works. I have created an array to hold all the text input field values. I now need some way of getting the index or order of the checkbox selected and then linking it to the appropriate index in the array so as to know this is the correct basket name to update. I am having a problem finding out how to get the 'order' or index of the checkbox selected.
I have no problem returning the basket id (which is the 'value' of the checkbox ticked). No problems at all with the basket itself). My only problem is updating the database with the basket name (this is an 'editable' field in the display grid) based on what the user has entered in the field AND which checkbox has been ticked. Each check box holds the basket id (as its value). This I can return no problem - the question is I can't 'link' up the checkbox in any way to the basket name text input field.
Ideally I would want to get the 'ID' or order of the checkbox that was ticked. And then use this index to return the associated index in the array (the array holds all the basket name input field values).
For example if I have 5 records being displayed. The user ticks the third checkbox down. I need a way of knowing that this is the THIRD checkbox. Then with the 'number 3' I can use this to return the item in the array with an index of 2 (as an array always starts at 0, so this would in effect therefore be the third basket name item in the array - and therefore the basket name 'linked' with the third checkbox that was ticked). My problem is I have no idea how to work out that it was the third checkbox ticked.
Is there any way to do this?
How would an onBlur example work?
Please can someone help me with this problem. Thank you very much for any help.
Here is the code that should be run when a user clicks an update 'button' (the input text field and checkbox field is at the bottom of the code):
'-------------------------------
'get the basket name that user has entered and put into array
formbasketname = Request.Form("sel_quotename")
formarray = Split(formbasketname,", ")
for j=0 to Ubound(formarray)
Response.Write "<br>" & formarray(j) 'TEST display contents of array - (this all works)
next 'move to next element in array
Set rsBasket = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT * FROM tvQuoteBasket_GetBasket WHERE user_id = " & userid
rsBasket.Open strSQL, cnnConn, 1, 4
rsBasket.MoveFirst
do
'get the checkbox value selected by the user - this holds the basketid value - (this works)
chkboxvalue = Request.Form("chkbox")(i)
'******NOW NEED TO GET THE BASKET NAME ENTERED BY USER THAT IS ASSOCIATED WITH THE CHECKBOX SELECTED
'******THEREFORE NEED SOME WAY TO GET THE 'ORDER' OF THE CHECKBOXES SELECTED. CURRENTLY 'i' JUST SHOWS THE TOTAL NUMBER OF CHECKBOXES SELECTED
'UPDATE DATABASE CODE GOES HERE (THIS IS NO PROBLEM) BUT NEED CORRECT VALUE OF BASKET NAME TO UPDATE WITH!
rsBasket.MoveNext
i = i + 1
loop until i = (Request.Form("chkbox").Count)
rsBasket.Close
'Code showing the checkbox filed and basket name input field - (this all works)
<INPUT type='checkbox' value='<%= basketid %>' name='chkbox'>
<input type="text" name="sel_quotename" value="<%=quotebasketname%>" maxlength="50" size="50">
'-------------------------------
Thank you for any help.