473,397 Members | 1,950 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,397 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 1417
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
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.