473,372 Members | 1,159 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,372 software developers and data experts.

Dynamic Variables with unknown constant

Hi All,

This one is a bit complex, so I'll try to be as logical explaining the issue as humanily possible.

ASP/VBScript/MySQL

Issue: Creating dynamic variables while there is an unknown constant

Example: Somebody uses a drop down menu to select the type of fruit. Let's say they select apples. Now directly underneathe, a table of checkboxes is returned with all the possible results (chkbx1 = granny's, chkbx2 = smith, chkbx3 = mcintosh, and so on). The possible chkbx's are contained within a MySQL table - retrieving/displaying them is no issue. But now, each of those checkboxes must have a separate variable attached when they are called through a DO WHILE...LOOP.

ie: chkbx1, chkbx2, chkbx3, etc.

However, if someone decided to choose a different fruit, and it produced 10 results with checkboxes, it would need to dimension 10 variables. This can vary for a variety of different selections - and while we know how many are in the database, we won't know which selection from the dropdown is going to be made - and not wanting to write unique code for each of the possible scenarios - I figure there must be an easier way.

I thought of running a self-adding interger in the loop to identify them - but I don't know how to actually dimension them before hand like this...and then know this amount so I can later check the boolean results of each.

If this makes sense and you can assist, I'd be greatful.

Thank you,
Jeremy
Aug 3 '07 #1
2 1416
jhardman
3,406 Expert 2GB
Jeremy,

from what I gather, I've done something similar. The last time I tried this I dimmed a gigantic array (like 200 items) and looped through them to put all of the inputs in their place. This was time consuming and probably not the best use of the cpu.

It might be better to give the inputs all the same name, then the post data should return this:
Expand|Select|Wrap|Line Numbers
  1. request("appleCheckBoxes") = "on,,,on,on"
and you can send these all to an array with the split command like this:
Expand|Select|Wrap|Line Numbers
  1. appleChecks = split(request("appleCheckBoxes"), ",")
  2. for each x in appleChecks
  3.    response.write x & ": " appleChecks(x) & "<br>" & vbNewLine
  4. next
This should return the following:
Expand|Select|Wrap|Line Numbers
  1. 0: on
  2. 1:
  3. 2:
  4. 3: on
  5. 4: on
does this help?

Jared
Aug 3 '07 #2
Hi Jared,

Thanks - yes this does help...ingenious, and I feel mental for not thinking of it myself. One of those many times that you stare at a problem for so long - you lose all comprehension of it.

Thanks again.
Cheers,
Jeremy


Jeremy,

from what I gather, I've done something similar. The last time I tried this I dimmed a gigantic array (like 200 items) and looped through them to put all of the inputs in their place. This was time consuming and probably not the best use of the cpu.

It might be better to give the inputs all the same name, then the post data should return this:
Expand|Select|Wrap|Line Numbers
  1. request("appleCheckBoxes") = "on,,,on,on"
and you can send these all to an array with the split command like this:
Expand|Select|Wrap|Line Numbers
  1. appleChecks = split(request("appleCheckBoxes"), ",")
  2. for each x in appleChecks
  3.    response.write x & ": " appleChecks(x) & "<br>" & vbNewLine
  4. next
This should return the following:
Expand|Select|Wrap|Line Numbers
  1. 0: on
  2. 1:
  3. 2:
  4. 3: on
  5. 4: on
does this help?

Jared
Aug 7 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: Dave Karmens | last post by:
If I have say 10 fixed variables, how can I set their values = to that of a form that is built dynamically? column1 column2 email = formvalue(0) fname = formvalue(1) lname = formvalue(2)...
2
by: Tommy Lang | last post by:
Hi everybody! I am trying to learn the basics of C++ myself and have a hard time understanding some stuff like pointers and references etc. I have created a small program that adds two numbers...
2
by: systemutvecklare | last post by:
Hi! I have an application that generates an html-form from an xml-file using an xsl-file. My problem is that I want the xsl to use some "unknown" parameters that I pass to the xslt processor...
1
by: Nathan Bloomfield | last post by:
Does anyone know if there is any documentation which relates to Access2k + ? or can anyone help adjust the code? I am having trouble converting the DAO references. TITLE :INF: How to...
2
by: deejayquai | last post by:
Hi I'm trying to produce a report based on a dynamic crosstab. Ultimately i'd like the report to actually become a sub report within a student end of year record of achievement. The dynamic...
0
by: jeoffh | last post by:
Background: I am trying to "merge" some attributes into an existing XML column in my MS SQL 2005 database. The general idea is that I have an XML column in a table and I would like to update/delete...
18
by: squaretriangle | last post by:
Is it possible through some trickery, perhaps using the methods of stdarg, to pass a dynamic (unknown at compile time) number of arguments to a function? For example, I want to enumerate an array...
11
by: Andrus | last post by:
I created dynamic extension methods for <= and < SQL comparison operators: public static IQueryable<TLessThanOrEqual<T>(this IQueryable<Tsource, string property, object value); public static...
14
ollyb303
by: ollyb303 | last post by:
Hi, I am trying to create a dynamic crosstab report which will display number of calls handled (I work for a call centre) per day grouped by supervisor. I have one crosstab query (Query1) which...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.