September 9th, 2011, 12:48 PM
Database fields to reference Arrays in ASP
As a relative beginner to ASP, please do not scream NEWBIE too loudly when reading/answering...
I have an ASP page that displays items for a user to choose by clicking a radio button to select. Rather than manually build each item's display I have stored all the attributes of the item in an Access database and build the display dynamically.
Since I need to reference the items later I load the attributes into arrays like this:
itemrow = 0
Do While Not recordset.EOF
itemradio(itemrow) = Recordset("radname")
itemdesc(itemrow) = Recordset("Item")
itemcost(itemrow) = Recordset("itemcost")
itemvalue(itemrow) = Recordset("itemvalue")
itemimage(itemrow) = Recordset("Image")
itemrow = itemrow + 1
In the database radname would contain values like:
When the form is submitted, I grab the value and store it in a field.
for (var i=0; i < document.form1.group1.length; i++)
var rad_val = document.form1.group1[i].value;
document.form1.chose.value = rad_val;
Here is where I have issues. I am sure it is something I am doing or perhaps the type of field in the database that is causing it, but when I attempt to reference the information using the code below I constantly get a Type Mismatch no matter what type of field I set it to in the Access database.
varchose = Request.form("chose")
Is there some type of conversion I need to do? I have tried setting the database field to text length 2, long, integer etc.
ANY help would be so greatly appreciated!!
Thanks in advance!
September 9th, 2011, 02:23 PM
Show a snippet of the actual code and identify what line in the code is causing your error. Often it's an unexpected null value in a variable you expected to have data.
You can also look at the recordset .getrows() method to automatically build an array from a recordset.
I've never been able to appreciate the sublime arrogance of folks who feel they were put on earth just to save other folks from themselves .." - Donald Hamilton
September 9th, 2011, 04:46 PM
is the line where it is giving me the Type Mismatch, I put it in there as a way to debug and verify that the correct array item was being chosen.