473,378 Members | 1,218 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,378 software developers and data experts.

String manipulation and category building.

I have been working in this problem for weeks and I was determined to sort
it myself however I feel I need guidance to proceed forward.

What I am trying to produce is some asp code that can split categories and
group from a text string that is delimited by a "| ". (see string examples
below). I have managed to find some javascript that will handle the
different levels of categories without having to keep refreshing the page.
So I want the asp code to split the categories in the javascript array's
(see java code below) and be flexible enough to handle different numbers of
sub categories as they can vary.

Any guidance or examples would be appreciated.

Thanks

Sean

---------------

String examples

Agriculture, Forestry & Fishing[1]|
Agriculture, Forestry & Fishing[1]|Growing of crops; market gardening;
horticulture
Agriculture, Forestry & Fishing[1]|Farming of animals
Agriculture, Forestry & Fishing[1]|Mixed farming
Agriculture, Forestry & Fishing[1]|Agricultural and animal husbandry service
activities, except veterinary activities
Agriculture, Forestry & Fishing[1]|Hunting, trapping and game propagation
and related service activities
Agriculture, Forestry & Fishing[1]|Forestry, logging and related service
activities
Agriculture, Forestry & Fishing[1]|Fishing, operation of fish hatcheries and
fish farms; service activities incidental to fishing
Energy and manufacture of mineral products[2]|
Energy and manufacture of mineral products[2]|Extraction of minerals, oils
and natural gas, and related service activities
Energy and manufacture of mineral products[2]|Glass and glass products

---------------

Java code

<script language="JavaScript" type="text/JavaScript"><!--

function comboItemSelected(oList1,oList2){
if (oList2!=null){
clearComboOrList(oList2);
if (oList1.selectedIndex == -1){
oList2.options[oList2.options.length] = new Option('Please make a selection
from the list', '');
} else {
fillCombobox(oList2, oList1.name + '=' +
oList1.options[oList1.selectedIndex].value);
}}}

function clearComboOrList(oList){
for (var i = oList.options.length - 1; i >= 0; i--){
oList.options[i] = null;
}
oList.selectedIndex = -1;
if (oList.onchange) oList.onchange();
}

function fillCombobox(oList, vValue){
if (vValue != '') {
if (assocArray[vValue]){
oList.options[0] = new Option('Please make a selection', '');
var arrX = assocArray[vValue];
for (var i = 0; i < arrX.length; i = i + 2){
if (arrX[i] != 'EOF') oList.options[oList.options.length] = new
Option(arrX[i + 1], arrX[i]);
}
if (oList.options.length == 1){
oList.selectedIndex=0;
if (oList.onchange) oList.onchange();
}
} else {
oList.options[0] = new Option('None found', '');
}}}
//--></script>

<body>
<p>
And this second example shows a pair of single-entry &quot;combo&quot;
pulldowns filled
with the same data:
</p>
<form name="firstexample" onsubmit="return(False);">
<table border="1" bgcolor="beige" align="center">
<tr>Publishers Titles</tr>

<tr><td>
<select name='list1' size='1' style='width:360;'
onchange='comboItemSelected(this,this.form.list2); '>
<option>Please make a selection</option>
<option value="Algodata Infosystems">Algodata Infosystems</option>
<option value="0877">Binnet & Hardley</option>
<option value="1622">Five Lakes Publishing</option>
<option value="9901">GGG&G</option>
<option value="9999">Lucerne Publishing</option>
<option value="0736">New Moon Books</option>
<option value="1756">Ramona Publishers</option>
<option value="9952">Scootney Books</option>
</select>

</td><td><p>
<select name='list2' size='1' style='width:360;'>
<option>Please select an item from the preceding list</option>
</select>

<script language='JavaScript' type="text/JavaScript">
//Arrays for menus
if (!assocArray) var assocArray = new Object();
assocArray["list1=0736"] = new Array(
"PS7777","Emotional Security: A New Algorithm",
"PS2091","Is Anger the Enemy?",
"PS2106","Life Without Fear",
"PS3333","Prolonged Data Deprivation: Four Case Studies",
"BU2075","You Can Combat Computer Stress!",
"EOF");
assocArray["list1=0877"] = new Array(
"PS1372","Computer Phobic AND Non-Phobic Individuals: Behavior
Variations",
"TC4203","Fifty Years in Buckingham Palace Kitchens",
"TC3218","Onions, Leeks, and Garlic: Cooking Secrets of the
Mediterranean",
"MC2222","Silicon Valley Gastronomic Treats",
"TC7777","Sushi, Anyone?",
"MC3021","The Gourmet Microwave",
"MC3026","The Psychology of Computer Cooking",
"EOF");
assocArray["list1=Algodata Infosystems"] = new Array(
"PC1035","But Is It User Friendly?",
"BU1111","Cooking with Computers: Surreptitious Balance Sheets",
"PC9999","Net Etiquette",
"PC8888","Secrets of Silicon Valley",
"BU7832","Straight Talk About Computers",
"BU1032","The Busy Executive's Database Guide",
"EOF");
</script>
</td>
</tr>
</table>
</form>
</body>

Jul 19 '05 #1
0 1548

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Rich Shepard | last post by:
I need to learn how to process a byte stream from a form reader where each pair of bytes has meaning according to lookup dictionaries, then use the values to build an array of rows inserted into a...
0
by: L'eau Prosper Research | last post by:
Press Release: L'eau Prosper Research (Website: http://www.leauprosper.com) releases new TradeStation 8 Add-on - L'eau Prosper Market Manipulation Profiling Tools Set. L'eau Prosper Market...
1
by: TomLasky | last post by:
Hi everyone, I'm creating a very powerful web store script in ASP. One of the things I am adding is to allow the user to create their own categories and sub categories for items they wish to sell....
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: 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: 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.