473,378 Members | 1,426 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.

How do i Dim dynamic information?

PLEASE forgive me! I have been a web designer for a few years now, and want to move on and learn a programming language.

Im currently building a website, and i have a js file that contains some info relating to a directory of taxis in the UK.

Copy pasting is getting boring now, so i wanted to automate and simplify the procedure so i can ask a few friends to contribute to the process (i couldnt ask my friends to open up a js file and expect them to understand it)

I have had very limited asp/vb experience, i can 'reverse engineer and tweak' scripts of asp/vb that the company i obtain my CMS from has written, but *creating* something is totally new to me.

First of all i wanted some input boxes that can POST info to a results page, but then i realised on one particular piece of info, i would need 20 input boxes. so i thought i would explore the loop aspect (aspect - the right phrase there?) so i didnt have to code 20 input boxes with different names etc. so i made a loop that creates:

District 1 : INPUTBOX (named d1)
District 2 : INPUTBOX (named d2)
District 3 : INPUTBOX (named d3)

and so on up to 20

It worked! Great ! But then i realised i had to dim them. And this is where i am really stuck.

Could someone please look over my code and offer a few directions i should be looking in? It would be much appreciated.

As it stands, the countyname and districts 1 & 2 are dim'd manually - so they actually provide a successful output, but i am looking for a way to write that dim line i have there and have it dim d1 thru to d20 dynamically.

Here is what i have:
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <body>
  3. Start a New County<br />
  4. -------------------------
  5. <form action="messabout.asp" method="post">
  6. County Name: <input type="text" name="countyname" size="40" /><br />
  7.  
  8. <%
  9.     for i=1 to 20
  10.     response.Write("District " & i & ":  <input type=""text"" name=""d" & i & """ size=""40"" /><br />" & vbcrlf & "")
  11.     next
  12.  
  13. %>
  14.  
  15. <input type="submit" value="Submit" />
  16. </form>
  17.  
  18.  
  19. <%
  20. // i need to know how to write this dim line with out manually writing d1,d2 thru to d20 - i created the input boxes fine, all with dx incrementing nicely, but this fails me
  21. dim countyname, d1, d2
  22. countyname=Request.form("countyname")
  23. d1=Request.form("d1")
  24. d2=Request.form("d2")
  25. If countyname<>"" Then
  26.       Response.Write("The County you created was: " & countyname & " <br />The first line is added to the main county list. The rest is the county itself<p>")
  27.       Response.Write("This is the code to add the county to config.js:<p><textarea rows=20 cols=100>addList(&quot;First-Select&quot;, &quot;" & countyname & "&quot;, &quot;&quot;, &quot;" & countyname & "&quot;); " & vbCrLf & vbCrLf &"///////////    " & countyname & "    ///////////" & vbCrLf & vbCrLf &"addOption(&quot;" & countyname & "&quot;, &quot;Select a District --&quot;, &quot;&quot;, 1); //HEADER OPTION" & vbCrLf &"addList(&quot;" & countyname & "&quot;, &quot;" & d1 & "&quot;, &quot;&quot;, &quot;" & d1 & "&quot;);" & vbCrLf &"")
  28. End If
  29.  
  30. If d2<>"" Then
  31.     response.Write("addList(&quot;" & countyname & "&quot;, &quot;" & d2 & "&quot;, &quot;&quot;, &quot;" & d2 & "&quot;);" & vbCrLf &"")
  32.     End if
  33. %>
  34.  
  35.  
  36.  
  37.  
  38. <% response.write("</textarea></p>") %>
  39.  
  40.  
  41. </body>
  42. </html>
Many thanks for your time,

Patrick Shelley (sidesteal)
Aug 3 '08 #1
4 1357
DrBunchman
979 Expert 512MB
Hi Patrick,

The short answer is 'You can't' - you just have to declare them all in a list.

However you could store the values that you are capturing in an array which might make your life a bit easier. Have you had any experience using arrays? Here's an example:
Expand|Select|Wrap|Line Numbers
  1. Dim d(20)
  2. For i = 1 to 20
  3.      d(i) = Request("d" & i)
  4. Loop
Let me know if this helps,

Dr B
Aug 4 '08 #2
Dr B - thank you for that!

I guess even though you answered 'you cant' - you then gave me the method to do it!

I havent looked into arrays - what other uses do they have?

Any way, since i posted my orginal thread, i decided to explore another method.

Writing the form data to a text file.

This is what i have to achieve this:

Expand|Select|Wrap|Line Numbers
  1. <%
  2. Dim countyname
  3. Dim districtname
  4. countyname = request.Form("countyname")
  5. districtname = request.Form("districtname")
  6. %>
  7.  
  8. <html>
  9. <head>
  10. <title>Form for Taxi Directory</title>
  11. </head>
  12. <body>
  13.  
  14.  
  15. <form name="taxi" method="post" action="mess.asp?countyname=<% request.Form("countyname") %>">
  16. County Name: <input name="countyname" type="text">
  17. District Name: <input name="districtname" type="text">
  18. <input type="submit" value="submit">
  19. </form>
  20.  
  21. <%
  22.  
  23. Dim fso
  24. Dim tst
  25.  
  26. Set fso=Server.CreateObject("Scripting.FileSystemObject")
  27. Set tst=fso.OpenTextFile ("C:\Domains\mysite.co.uk\wwwroot\countys.txt", 8, true)
  28. response.Write("<p>Note - Will probably never need this line, but here it is anyway:</p>addList(&quot;First-Select&quot;, &quot;" & request.Form("countyname") & "&quot;, &quot;&quot;, &quot;" & request.Form("countyname") & "&quot;);")
  29. response.Write("<a href=""countys.txt""><h4>*CHECK TO SEE WRITTEN FILE</a> * YOU WILL HAVE TO REFRESH THE TEXT FILE TO SEE FRESH DATA</h4>")
  30.  
  31. if request.Form("countyname")<>"" Then
  32. tst.writeline ""
  33. tst.writeline "///////////    " & request.Form("countyname") & "    ///////////"
  34. tst.writeline ""
  35. tst.writeline "addOption(""" & request.Form("countyname") & """, ""Select a District --"", """", 1); //HEADER OPTION"
  36. end if
  37.  
  38. if request.Form("districtname")<>"" then
  39. tst.writeline "addList(""" & request.Form("countyname") & """, """ & request.Form("districtname") & """, """", """ & request.Form("districtname") & """);"
  40. end if
  41.  
  42. response.Write("<h3>Info that was written:</h3>")
  43. response.Write("County Name: ") 
  44. response.Write request.Form("countyname")
  45. response.Write("<br />District Name: ") 
  46. response.Write request.Form("districtname")
  47.  
  48.  
  49. tst.close
  50. Set tst = Nothing
  51. Set fso = Nothing
  52.  
  53. %>
  54.  
  55.  
  56. </body>
  57. </html>
  58.  
  59.  
But i run into a problem....

On first page load, i enter the county and the first district, hit submit. I can then view the file it created and wrote to.

At that point, i just need to enter a few more districts, but the countyname HAS to be in the output - and that variable is not carried/passed on past that first submit.

I have tried GET and POST - thinking that at least with GET i could grab data off the URL, but no joy. I automatically assumed that becuase the page posts results to itself - thet variables would still be 'in memory' and available to call upon.

This method is better for what i want to simpify (easier data entry in a format that is used in a js file) - and success will shave weeks off of the company listings i have to input from 80 counties x 6(average) districts per county x 5 listings per districts.......

I really need to know how/why to make that countyname variable stay constant.

Big thanks,

Patrick Shelley
Aug 4 '08 #3
I have been thinking on this -

If i could make the countyname input box retain its value after the form has been submitted - all would be fine. How would i achieve this?

Many thanks,

Patrick Shelley
Aug 4 '08 #4
DrBunchman
979 Expert 512MB
Hi Patrick,

To retain the value of an input across form submits you can do the following:
Expand|Select|Wrap|Line Numbers
  1. <input name="countyname" type="text" value="<%=Request("countyname")%>">
This will set the value of the textbox to the submitted value.

Dr B
Aug 5 '08 #5

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

Similar topics

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...
9
by: Gibby Koldenhof | last post by:
Hiya, Terrible subject but I haven't got a better term at the moment. I've been building up my own library of functionality (all nice conforming ISO C) for over 6 years and decided to adopt a...
13
by: Chris Thunell | last post by:
I have created several grids dynamically and have added them to different HTML placeholders on a vb.net web form. The grids and controls within them come up and view beautifully when the web page...
3
by: piscogirl | last post by:
Hi there, I am about to build a small db in Access. Among the tables I plan to have are a Person table, an Event table, and an EventRegistration table. The EventRegistration table will...
7
by: Joey | last post by:
I don't care what .net language this come in but I really need to determine if a disk is dynamic or basic. I have posted something in the WMI group but no one knows how to do it. Does anyone have...
10
by: jflash | last post by:
Hello all, I feel dumb having to ask this question in the first place, but I just can not figure it out. I am wanting to set my site up using dynamic urls (I'm assuming that's what they're...
2
by: assgar | last post by:
Hi Developemnt on win2003 server. Final server will be linux Apache,Mysql and PHP is being used. I use 2 scripts(form and process). The form displays multiple dynamic rows with chechboxs,...
6
by: KeithJ | last post by:
Hello, I am fairly new to VB6 and I am experiencing a problem with a dynamic array. I made a program that calculates Body Mass Index and saves each individual BMI number to a sequential disk...
2
by: doomer | last post by:
Hello, I'm trying to build a set of classes that act as the handlers for a simple expression parser, and i'm wondering how to preserve the dynamic type information from derived classes. An...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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:
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
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...

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.