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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ANOTHER Javascript FOR loop iteration 1

Status
Not open for further replies.

ghloid

IS-IT--Management
Mar 11, 2002
85
US
Hey again everyone,

This problem should make you about as crazy as me now. It's pretty complicated (for my algebraic ignorant self that is), so get ready. A few days ago, I posted another topic on a JavaScript FOR loop iteration I was trying to figure out (see thread216-600235). I'm trying something very similar now with a different layout. The whole point of both of these projects is to get automated seating charts for our bar exam. So, the first two were easy because they are standard rectangle shaped areas with seat numbering going from left to right starting at the bottom of the screen. Now though, I've got a slightly different set up.

I have a pyramid (if you will) on it's side with the apex of the pyramid being on the left hand side of the form. The form base of the pyramid is therefore on the right hand side. To see a good description of what I'm talking about, visit this site:


It's a PDF (as you can see) and the grid layout is what I have to number. If you have Acrobat, you can see the script in the populate button. It's basic JavaScript with some Adobe mods (the getField notation for example).

At any rate, what I have to do is start the numbering at the top right hand side, and go across the first row till it is complete. Then the next row (having more seats) should be filled with numbers going from right to left continuing the same sequencing order. So, for example, the top right square might be 1 (or whatever the user selects as the seating numbering should start with a USER defined prompt), and the numbering would continue down the grid till the very last row of 5 tables on the bottom.

The actual fields on this form are in numeric sequence as well (thinking that would make it easier). It's similar to the way I set the fields described in my first thread. That is, the first row is named (starting at upper right hand corner):

ASeat1.0
ASeat1.1
ASeat1.2
ASeat1.3...ASeat1.5

The next row starts at:
ASeat2.0
ASeat2.1
ASeat2.2...ASeat2.5 THEN
ASeat1.6
ASeat1.7
ASeat1.8
ASeat1.9

Then the next row goes like:
ASeat3.0...ASeat3.5
ASeat2.6...ASeat2.9
ASeat1.10
ASeat1.11

The next row would then be:
ASeat4.0...ASeat4.5
ASeat3.6...ASeat3.9
ASeat2.10...ASeat2.11

And this continues onward till it starts the slope again. Therefore, the 10th row would be like:
ASeat10.0...ASeat10.5
ASeat9.6...ASeat9.9
ASeat8.10...ASeat8.11

The 11th would be the same, and the 12th would be:
ASeat12.0...ASeat12.5
ASeat11.6...ASeat11.9

And finally, the 13th row would be:
ASeat13.0...ASeat13.5

It's a kind of crazy numbering setup, but it DOES have a sequence there. It was the easiest to do through automation. Otherwise, I would have had to create every field name itself which would get pretty miserable.

Well, I hope that explains it somewhat. I'll be looking at it too to see if I can't make it easier or something.

If anyone has any ideas, please let me know.

THANKS!!!
 
i think your current numbering scheme is going to create too many problems...why would you want to simultaneously call the same row row 3, row 2 and row1?

why not number something like this?

<script type=&quot;text/javascript&quot;>
seats = [null,6,10,12,12,14,14,14,14,14,12,12,10,6];

for (var row = 1; row <= seats.length; row++) {
for (var seat = 0; seat < seats[row]; seat++) {
document.write(&quot;seat &quot; + row + &quot;.&quot; + seat + &quot;<br/>&quot;);
}
document.write(&quot;<br/>&quot;)
}
</script>



=========================================================
try { succeed(); } catch(E) { tryAgain(); }
-jeff
 
I think you are DEFINITELY right about the numbering situation for the fields. I will have to do some renaming. I only originally did it that way because it was easier to create them in bulk like that.

I'm going to try that (your idea), and I'll let you know what I come up with.

THANKS!!!
 
jemminger right as usual.
ghloid: This will give you a fast idea of what to expect.

<body>
<form name=&quot;pdftest&quot;>
<script type=&quot;text/javascript&quot;>
seats = [null,6,10,12,12,14,14,14,14,14,12,12,10,6];
var x=parseInt(prompt('Start with number','1')); //change this to whatever number coming from the prompt;

for (var row = 1; row <= seats.length; row++) {
for (var seat = 0; seat < seats[row]; seat++) {

document.write(&quot;<input type='text' size='2' name='seat &quot; + row + &quot;.&quot; + seat + &quot;' value='&quot;+ (x++) +&quot;'>&quot;);
}
document.write(&quot;<br/>&quot;);
}
</script>
</form>
</body>

I just added the extra x++ and some html.

My first impression after looking at your naming convention in your PDF file was that you wanted to create something like the magic square but in a triangle... which really got me thinking but after re-reading I think jemminger is correct and that is the easiest way to go.

A * on me.

grtfercho çB^]\..
&quot;Imagination is more important than Knowledge&quot; A. Einstein
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top