Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

add a number to a dynamic field or serialize? 1

Status
Not open for further replies.

evr72

MIS
Dec 8, 2009
265
US
hello,

I was wondering if I can serialize a dynamic field, for example fi the name of the field is myfield, when I execute my asp code and the page displays the "myfield" field would show up as
myfield1
myfield2
myfield3... and so on?

I tried
Code:
<select name="<%
myvalue = myfield
response.write myvalue + 1
%>">

but no luck, it just put a 1 instead of myfield1
 
Code:
for i = 1 to 10
 response.write  "myfield" & i
next
 
foxbox, thanks but I get the following error

Error Type:
Microsoft VBScript compilation (0x800A0401)
Expected end of statement
 
???

that should result in:
"myfield1myfield2myfield3myfield4myfield5myfield6myfield7myfield8myfield9myfield10"


Did you enclose this with "<%" and "%>" ?

 
yes, this is what I have

Code:
	        <select name="<% for i = 1 to 10 response.write  "repl" & i next %>">
	          <option>---</option>
	          <option>Yes</option>
	           <option>No</option>
			   <option>Other</option>
			   <option>N/A</option>
            </select>

[code]
 
If this is for your test thing with the 1,000 questions that you talked about in the other thread the last thing you want is nonnormalized data. Fields with repeating names like repl1, repl2, repl3, repl4, etc would suggest that is what is going on.

You might want to consider clueing us into the larger picture of what you want to do.

As for the specific question you asked, you might look at:
Code:
<% for i = 1 to 10 %>
<select name="repl<%= i %>">
 <option>---</option>
 <option>Yes</option>
 <option>No</option>
 <option>Other</option>
 <option>N/A</option>
</select>
<% next %>
 
Mr. BigRed1212

I tried your suggestion and it works, but it gives me 10 selects in one row

Code:
select name="repl1">
 <option>---</option>
 <option>Yes</option>
 <option>No</option>
 <option>Other</option>
 <option>N/A</option>
</select>
select name="repl2">
 <option>---</option>
 <option>Yes</option>
 <option>No</option>
 <option>Other</option>
 <option>N/A</option>
etc..
</select>
and on the next row the same thing
 
Yes it does. What did you want?

I would suggest styling the selects with some CSS or maybe inserting a <br> after the </select> inside the loop.

 
Mr. BigRed1212 I really appreciate the suggestion, but not very familiar with CSS.

foxbox, I appreciate the help and suggestions!!

I tried
Code:
<select name="repl<% = rs1Guestbook("itm") %>">
and it seems to work, the itm is a number in each row.

Thank you Both!!! I really appreciate all the help in my dark programming jorney!!!! :)
 
The script (program) you write must produce the HTML code you want. So you could start with a design, then create HTML of it, and then start looking for the repetition.

Code:
<%
for i = 1 to 10 
 response.write "<select name=""repl"" & i & ">" 
 
 ' Each select has the same answers
 response.write "<option>---</option>" & _
   "<option>Yes</option>" & _
   "<option>No</option>"

 'Terminate this SELECT
 response.write "</select>"

 'New line after this SELECT
 response.write "<br>"

 'Oke, and a line to:
 response.write "<hr>"

next



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top