Please Help: Script Logic/Multidimensional Array

P

pbd22

Hello. I would really appreciate some help. I am doing my
best to explain my problem and your patience is very appreciated.
thanks.

I have a page that allows users to upload multiple files at once to a
remote file server. I am creating the script to handle the client
actions and need some help.

the problem:

for each file that gets added to the upload queue, data from the
page's inputs needs to get saved in an array prior to submit. How do I
approach this?

my (current) solution:

I have a class (called MultiUpload) that gets instantiated as so:

window.addEvent('domready', function() {
new
MultiUpload( document.getElementById( 'uploadForm' ).my_file_input_element,
0, '{id}', true, true ); });

The MultiUpload class has a number of inner functions, the ones
relevant here are addRow:function() which adds a new <DIV> row for
each uploaded file. Inside of addRow is the Element declaration for a
span where the name of the file is contained:

var item = new Element(
'span',
{
'class':'item',
'events':{
'click':function(uid){
this.activeRow( uid );
}.pass( current_element.uid, this )
}
}
).setText( name );

current_element is the element that has been currently added to the
queue (of array elements[]) and uid is its order (0,1,2,3,4...).

The span is given a 'click' event with function this.activeRow called.
The function attempts to do the following:

1) the first for loop (var f) searches the form for data input fields
and adds them to the array inputs.
2) the next for loop (var i) sets the count for the number of files
currently in the upload queue. "global_cnt" is always the limit or
last added file count.
3) the last for loop (var j) sets the number of the data inputs as the
limit.

Now, when the outter loop equals the current selected file (i == uid),
I attempt to use a multidimensional array to either populate the
feilds if data has already been set:

if(fileQueue[j]){ inputs[j].value =
fileQueue[j];

or store data if the user has entered something:

inputs[j].onchange=function(){
fileQueue[j] = inputs[j].value;
}

I am currently neither getting an error from try/catch nor getting the
code to store data and repopulate fields when I click on a file link.
So, I am not quite sure where to go from here....

Below is activeRow:

activeRow:function( uid ){

try {

var frm = document.uploadForm;
var inputs = new Array();

// Discover the data elements
for (var f = 0; f < frm.elements.length; f++)
{
if (frm.elements[f].className == "input") {
inputs[inputs.length] = frm.elements[f];
}
}

var fileQueue = new Array(global_cnt);

// Sort through files selected
for (var i=0; i<=global_cnt; i++) {

// If the file was clicked
if (i == uid) {

fileQueue = new Array(inputs.length);

for (var j=0; j < inputs.length; j++)
{
if(fileQueue[j]){
inputs[j].value = fileQueue[j];
}

if (inputs[j].onChanged)
fileQueue[j] = inputs[j].value;

}

}

}

}catch(e){alert(e.message);}

},



Finally, for what it is worth, below is my form HTML. I have been
advised to add it, so, sorry in advance to the "post lightly" camp:

<form id="uploadForm" name="uploadForm" method="POST"
enctype="multipart/form-data"
action="progress.aspx"
target="uploadFrame" onsubmit="return (callToServer(this.name))"
style="padding: 10px;">
<div id="set_one" style="background-
color: rgb(176, 229, 124); margin: 10px;">
<label style="width: 85px; text-
align: right; float: left;">
Video file:&nbsp;
</label>
<input id="my_file_input_element"
type="file" name="file_1" />
<div style="display: none"
id="video-file-error" class="error-text">
Required field cannot be left
blank
<br />
</div>

<br />
<label style="width: 85px; text-
align: right; float: left;">
Title:&nbsp;
</label>
<input class="input" name="title"
id="title" maxlength="255" type="text"
size="53"
onchange="onTitleChange();">
<br />
<div style="display: none"
id="title-error" class="error-text">
<label>
Required field cannot be
left blank</label>
<br>
</div>
<br />
<label style="width: 85px; text-
align: right; float: left;">
Description:&nbsp;
</label>
<textarea class="input" rows="6"
cols="40" name="description" id="description"
onchange="onDescChange();"></
textarea>
<div style="display: none"
id="description-error" class="error-text">
Required field cannot be left
blank
<br>
</div>
<br />
<br />
<label style="width: 85px; text-
align: right; float: left;">
Tags:&nbsp;
</label>
<input name="tags" id="tags"
maxlength="255" type="text" class="input" size="53">
<br />
<br />
<label style="width: 85px; text-
align: right; float: left;">
Category:&nbsp;
</label>
<select class="input"
id="category" name="category">
<option value="[Select
category]" selected>[Select category]</option>
<option value="Attic">Attic</
option>
<option
value="Backyard">Backyard</option>
<br>
<div style="display: none"
id="genre-error" class="error-text">
Required field cannot be left
blank
<br>
</div>
<br />
<label style="width: 85px; text-
align: right; float: left;">
Language:&nbsp;</label>
<select class="input"
id="language" name="language">
<option value="[Select
language]">[Select language]</option>
<option value="AB">Abkhazian </
option>
<option value="AA">Afar </
option>
<option value="AF">Afrikaans </
option>
<option value="ZU">Zulu </
option>
</select>
<br>
<div style="display: none"
id="language-error" class="error-text">
Required field cannot be left
blank
<br>
</div>
</div>
<!-- END SET ONE -->
<div id="set_two" style="background-
color: rgb(176, 229, 124); margin: 10px;">
<span><span style="float: left;">
<label style="width: 85px;
text-align: right; margin-left: 10px;">
<b>Access:</b>&nbsp;
</label>
<label>
Public by default</label>
</span><span style="float: right;
margin-right: 10px;" onclick="expCollapse('set2', 'img2')">
<label style="text-decoration:
underline; color: Blue; cursor: pointer;">
Edit</label>&nbsp;<img
id="img2" src="../icons/btn_down.gif" style="cursor: pointer;" /></
span></span>
<div style="clear: both;">
</div>
<div id="set2" style="margin-left:
10px; display: none;">
<p>
<input class="input"
type="radio" name="public" value="public">
<label>
Public - your video
will be included in search results.
</label>
<br>
<input type="radio"
checked name="unlisted" class="input" value="unlisted">
<label>
Unlisted - your video
will <b>not</b> be included in search results.
</label>
</p>
</div>
</div>
<!-- END SET TW0 -->
<div id="set_three" style="background-
color: rgb(176, 229, 124); margin: 10px;">
<span><span style="float: left;">
<label style="width: 85px;
text-align: right; margin-left: 10px;">
<b>Video Location:</
b>&nbsp;
</label>
<label>
Public by default</label>
</span><span style="float: right;
margin-right: 10px;" onclick="expCollapse('set3', 'img3')">
<label style="text-decoration:
underline; color: Blue; cursor: pointer;">
Edit</label>&nbsp;<img
id="img3" src="http://www.trezoro.com/icons/btn_down.gif"
style="cursor: pointer;" /></span>
</span>
<div style="clear: both;">
</div>
<div id="set3" style="display:
none;">
<p>
<label style="width: 85px;
text-align: right; float: left;">
Address:&nbsp;</label>
<input class="input"
type="text" size="30" name="address">
<input type="button"
onclick="javascript:showAddress(this.form.address.value, 14); return
false;" value="" />

<br />
<br />
<label style="width: 85px;
text-align: right; float: left;">
Location:&nbsp;</
label>
<input type="text"
id="coords" name="coords" size="53" class="input" style="border-
style:none; color:Black; background-color:Transparent;" />
<br />
<br />
</p>
</div>
</div>
<!-- END SET THREE -->
<div id="set_four" style="background-
color: rgb(176, 229, 124); margin: 10px;">
<span><span style="float: left;">
<label style="width: 85px;
text-align: right; margin-left: 10px;">
<b>Privacy:</b>&nbsp;
</label>
<label>
Public by default</label>
</span><span style="float: right;
margin-right: 10px;" onclick="expCollapse('set4', 'img4')">
<label style="text-decoration:
underline; color: Blue; cursor: pointer;">
Edit</label>&nbsp;<img
id="img4" src="../icons/btn_down.gif" style="cursor: pointer;" /></
span>
</span>
<div style="clear: both;">
</div>
<div id="set4" style="margin-left:
10px; display: none;">
<p>
<span style="float:
left;">
<label style="float:
left; margin-left: 10px;">
<b>Comments:</b></
label>
<span style="float:
right; margin-right: 10px; width: 275px;">
<input
type="radio" checked name="comments" class="input">
<label
style="width: 100px;">
Allow all
comments without approval.</label>
<br />
<input
type="radio" name="comments" class="strangers">
<label
style="width: 100px;">
I must approve
comments from strangers.</label>
<br />
<input
type="radio" name="comments" class="input">
<label
style="width: 100px;">
I must approve
all comments.</label>
<br />
<input
type="radio" name="comments" class="input">
<label
style="width: 100px;">
Disable all
comments on this video.</label>
<br />
</span></span><span
style="float: left; margin-top: 10px;">
<label
style="float: left; margin-left: 10px;">
<b>Ratings:</
b></label>
<span
style="float: right; margin-right: 10px; width: 275px;">
<input
type="radio" checked name="ratings" class="input">
<label
style="width: 100px;">
Allow
users to rate this video.</label>
<br />
<input
type="radio" name="ratings" class="input">
<label
style="width: 100px;">
Disable
ratings on this video.</label>
<br />
</span></
span><span style="float: left; margin-top: 10px;">
<label
style="float: left; margin-left: 10px;">

<b>Embedding:</b></label>
<span
style="float: right; margin-right: 10px; width: 275px;">
<input
type="radio" checked name="embedding" class="input">
<label
style="width: 100px;">
Allow
anybody to show this video.</label>
<br />
<input
type="radio" name="embedding" class="input">
<label
style="width: 100px;">
Keep
the video on this site only.</label>
<br />
</span></span>
</p>
</div>
<div style="clear: both;">
</div>
</div>
<div id="set_five" style="background-
color: rgb(176, 229, 124); margin: 10px;">
<span><span style="float: left;">
<label style="width: 85px;
text-align: right; margin-left: 10px;">
<b>Date and Time:</
b>&nbsp;
</label>
<label>
Today by default</label>
</span><span style="float: right;
margin-right: 10px;" onclick="expCollapse('set5', 'img5')">
<label style="text-decoration:
underline; color: Blue; cursor: pointer;">
Edit</label>&nbsp;<img
id="img5" src="../icons/btn_down.gif" style="cursor: pointer;" /></
span></span>
<div style="clear: both;">
</div>
<div id="set5" style="margin-left:
10px; display: none;">
<p>
<label style="width: 85px;
text-align: right; float: left;">
Date:&nbsp;
</label>
<select id="recorded_mo"
name="recorded_mo" class="input">
<option value="0">---</option>
<option value="1">January</
option>
<option value="2">Feburary</
option>

<option value="12">December</option>
</select>
<select id="recorded_day"
name="recorded_day" class="input">
<option value="0">---</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>

<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>

<option value="31">31</option>
</select>
<select id="recorded_yr"
name="recorded_yr" class="input">
<option value="0">---</option>
<option value="2007">2007</
option>
<option value="2006">2006</
option>
<option value="2005">2005</
option>
<option value="2004">2004</
option>
</select>
<input id="today" value="Today"
onclick="todayDate();" type="button">
<input id="reset" value="Reset"
onclick="clearDate();" type="button">
<br />
<br />
<label style="width: 85px; text-
align: right; float: left;">
From:&nbsp;
</label>
<select id="frmtime_hour"
name="frmtime_hour" class="input">
<option value="0">---</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
</select>
<select id="frmtime_minutes"
name="frmtime_minutes" class="input">
<option value="0">---</option>
<option value="1">00</option>
<option value="2">15</option>
<option value="3">30</option>
<option value="4">45</option>
</select>
<select id="frmtime_ampm"
name="frmtime_ampm" class="input">
<option value="0">---</option>
<option value="1">AM</option>
<option value="2">PM</option>
</select>
<br />
<br />

<label style="width: 85px; text-
align: right; float: left;">
To:&nbsp;
</label>
<select id="totime_hour"
name="totime_hour" class="input">
<option value="0">---</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
</select>
<select id="totime_minutes"
name="totime_minutes" class="input">
<option value="0">---</option>
<option value="00">00</option>
<option value="15">15</option>
<option value="30">30</option>
<option value="45">45</option>
</select>
<select id="totime_ampm"
name="totime_ampm" class="input">
<option value="0">---</option>
<option value="1">AM</option>
<option value="2">PM</option>
</select>
<input id="Button1" value="All
Day" onclick="allDay();" type="button">
</p>
</div>
</div>
<div>
<center>
<input type='submit'
id="submitupload" value='Upload Video(s)' name="" />
</center>
</div>
<p>
</p>
</form>
 
D

David Mark

Hello. I would really appreciate some help. I am doing my
best to explain my problem and your patience is very appreciated.
thanks.

I have a page that allows users to upload multiple files at once to a
remote file server. I am creating the script to handle the client
actions and need some help.

the problem:

for each file that gets added to the upload queue, data from the
page's inputs needs to get saved in an array prior to submit. How do I
approach this?

my (current) solution:

You mean your current approach that is not quite a solution yet.
I have a class (called MultiUpload) that gets instantiated as so:

A class? You haven't got the basic concept working yet and already
you are wrapping an object around it? And since you call it a class,
I assume Prototype is mixed up in this.
window.addEvent('domready', function() {

I knew it. Why would you add all of this extra stuff when you are
still trying to debug your form submission logic.
new
MultiUpload( document.getElementById( 'uploadForm' ).my_file_input_element,

Use the forms object to reference the form. Make sure it exists and
then use its elements property to reference the input element.
0, '{id}', true, true ); });

The MultiUpload class has a number of inner functions, the ones
relevant here are addRow:function() which adds a new <DIV> row for
each uploaded file. Inside of addRow is the Element declaration for a
span where the name of the file is contained:

var item = new Element(
'span',
{
'class':'item',
'events':{
'click':function(uid){
this.activeRow( uid );
}.pass( current_element.uid, this )
}
}
).setText( name );

70K+ for this? It it fairly clear what this Prototypian code does,
but it would be much clearer if you used standard DOM methods to
create your element.
current_element is the element that has been currently added to the
queue (of array elements[]) and uid is its order (0,1,2,3,4...).

So uid is actually an index?
The span is given a 'click' event with function this.activeRow called.

I see (sort of.)
The function attempts to do the following:

1) the first for loop (var f) searches the form for data input fields
and adds them to the array inputs.
2) the next for loop (var i) sets the count for the number of files
currently in the upload queue. "global_cnt" is always the limit or
last added file count.
3) the last for loop (var j) sets the number of the data inputs as the
limit.

Simple as 1, 2, 3. But seriously, I hope the code is easier to follow
than your explanation.
Now, when the outter loop equals the current selected file (i == uid),
I attempt to use a multidimensional array to either populate the
feilds if data has already been set:

if(fileQueue[j]){ inputs[j].value =
fileQueue[j];

or store data if the user has entered something:

inputs[j].onchange=function(){
fileQueue[j] = inputs[j].value;

}

I am currently neither getting an error from try/catch nor getting the


Using try/catch for debugging is a bad idea.
code to store data and repopulate fields when I click on a file link.
So, I am not quite sure where to go from here....

First remove Prototype and any instances of try/catch from the
equation.
Below is activeRow:

activeRow:function( uid ){

try {

var frm = document.uploadForm;

Use the forms object.
var inputs = new Array();

// Discover the data elements
for (var f = 0; f < frm.elements.length; f++)
{
if (frm.elements[f].className == "input") {

That's an ill-advised name for a class. And why not check the input's
type?
inputs[inputs.length] = frm.elements[f];
}
}

var fileQueue = new Array(global_cnt);

That may be the worst variable name ever (global_cnt.) And where is
it declared and defined?
// Sort through files selected
Sort?

for (var i=0; i<=global_cnt; i++) {

Looks like one too many iterations.
// If the file was clicked

Rather if some span was clicked.
if (i == uid) {

The uid variable is actually an index, right?
fileQueue = new Array(inputs.length);

for (var j=0; j < inputs.length; j++)
{
if(fileQueue[j]){
inputs[j].value = fileQueue[j];
}

if (inputs[j].onChanged)


What is "onChanged?"
fileQueue[j] = inputs[j].value;

}

}

}

}catch(e){alert(e.message);}

},

Finally, for what it is worth, below is my form HTML. I have been
advised to add it, so, sorry in advance to the "post lightly" camp:


You need to post what is relevant to the problem. Looks like you need
to post more of your script and a lot less HTML.
<form id="uploadForm" name="uploadForm" method="POST"
enctype="multipart/form-data"
action="progress.aspx"
target="uploadFrame" onsubmit="return (callToServer(this.name))"
style="padding: 10px;">
<div id="set_one" style="background-
color: rgb(176, 229, 124); margin: 10px;">

That's an odd way to specify a background color? And where is the
color rule? What if a browser's default text color is rgb(176, 229,
124)?
<label style="width: 85px; text-
align: right; float: left;">

Don't define the width of a label in pixels (use ems.)
Video file:&nbsp;

And this label is for..?
<input id="my_file_input_element"
type="file" name="file_1" />
<div style="display: none"
id="video-file-error" class="error-text">

Some agents can't change display properties with script.
Required field cannot be left
blank
<br />

Is this an XHTML page?

[snip more of the same]

Or is it HTML after all?

[snip more irrelevant HTML]
<label style="text-decoration:
underline; color: Blue; cursor: pointer;">
Why?

[snip]

<center>

Don't use the center tag.
<input type='submit'
id="submitupload" value='Upload Video(s)' name="" />

Why an empty name?
</center>
</div>
<p>
</p>

Why an empty paragraph?

I must have missed the relevant part. Just post the "HTML" that
relates to the script in question.
 
P

pbd22

Hello. I would really appreciate some help. I am doing my
best to explain my problem and your patience is very appreciated.
thanks.

I have a page that allows users to upload multiple files at once to a
remote file server. I am creating the script to handle the client
actions and need some help.

the problem:

for each file that gets added to the upload queue, data from the
page's inputs needs to get saved in an array prior to submit. How do I
approach this?

my (current) solution:

I have a class (called MultiUpload) that gets instantiated as so:

window.addEvent('domready', function() {
new
MultiUpload( document.getElementById( 'uploadForm' ).my_file_input_element,
0, '{id}', true, true ); });

The MultiUpload class has a number of inner functions, the ones
relevant here are addRow:function() which adds a new <DIV> row for
each uploaded file. Inside of addRow is the Element declaration for a
span where the name of the file is contained:

var item = new Element(
'span',
{
'class':'item',
'events':{
'click':function(uid){
this.activeRow( uid );
}.pass( current_element.uid, this )
}
}
).setText( name );

current_element is the element that has been currently added to the
queue (of array elements[]) and uid is its order (0,1,2,3,4...).

The span is given a 'click' event with function this.activeRow called.
The function attempts to do the following:

1) the first for loop (var f) searches the form for data input fields
and adds them to the array inputs.
2) the next for loop (var i) sets the count for the number of files
currently in the upload queue. "global_cnt" is always the limit or
last added file count.
3) the last for loop (var j) sets the number of the data inputs as the
limit.

Now, when the outter loop equals the current selected file (i == uid),
I attempt to use a multidimensional array to either populate the
feilds if data has already been set:

if(fileQueue[j]){ inputs[j].value =
fileQueue[j];

or store data if the user has entered something:

inputs[j].onchange=function(){
fileQueue[j] = inputs[j].value;

}

I am currently neither getting an error from try/catch nor getting the
code to store data and repopulate fields when I click on a file link.
So, I am not quite sure where to go from here....

Below is activeRow:

activeRow:function( uid ){

try {

var frm = document.uploadForm;
var inputs = new Array();

// Discover the data elements
for (var f = 0; f < frm.elements.length; f++)
{
if (frm.elements[f].className == "input") {
inputs[inputs.length] = frm.elements[f];
}
}

var fileQueue = new Array(global_cnt);

// Sort through files selected
for (var i=0; i<=global_cnt; i++) {

// If the file was clicked
if (i == uid) {

fileQueue = new Array(inputs.length);

for (var j=0; j < inputs.length; j++)
{
if(fileQueue[j]){
inputs[j].value = fileQueue[j];
}

if (inputs[j].onChanged)
fileQueue[j] = inputs[j].value;

}

}

}

}catch(e){alert(e.message);}

},

Finally, for what it is worth, below is my form HTML. I have been
advised to add it, so, sorry in advance to the "post lightly" camp:

<form id="uploadForm" name="uploadForm" method="POST"
enctype="multipart/form-data"
action="progress.aspx"
target="uploadFrame" onsubmit="return (callToServer(this.name))"
style="padding: 10px;">
<div id="set_one" style="background-
color: rgb(176, 229, 124); margin: 10px;">
<label style="width: 85px; text-
align: right; float: left;">
Video file:&nbsp;
</label>
<input id="my_file_input_element"
type="file" name="file_1" />
<div style="display: none"
id="video-file-error" class="error-text">
Required field cannot be left
blank
<br />
</div>

<br />
<label style="width: 85px; text-
align: right; float: left;">
Title:&nbsp;
</label>
<input class="input" name="title"
id="title" maxlength="255" type="text"
size="53"
onchange="onTitleChange();">
<br />
<div style="display: none"
id="title-error" class="error-text">
<label>
Required field cannot be
left blank</label>
<br>
</div>
<br />
<label style="width: 85px; text-
align: right; float: left;">
Description:&nbsp;
</label>
<textarea class="input" rows="6"
cols="40" name="description" id="description"
onchange="onDescChange();"></
textarea>
<div style="display: none"
id="description-error" class="error-text">
Required field cannot be left
blank
<br>
</div>
<br />
<br />
<label style="width: 85px; text-
align: right; float: left;">
Tags:&nbsp;
</label>
<input name="tags" id="tags"
maxlength="255" type="text" class="input" size="53">
<br />
<br />
<label style="width: 85px; text-
align: right; float: left;">
Category:&nbsp;
</label>
<select class="input"
id="category" name="category">
<option value="[Select
category]" selected>[Select category]</option>
<option value="Attic">Attic</
option>
<option
value="Backyard">Backyard</option>
<br>
<div style="display: none"
id="genre-error" class="error-text">
Required field cannot be left
blank
<br>
</div>
<br />
<label style="width: 85px; text-
align: right; float: left;">
Language:&nbsp;</label>
<select class="input"
id="language" name="language">
<option value="[Select
language]">[Select language]</option>
<option value="AB">Abkhazian </
option>
<option value="AA">Afar </
option>
<option value="AF">Afrikaans </
option>
<option value="ZU">Zulu </
option>
</select>
<br>
<div style="display: none"
id="language-error" class="error-text">
Required field cannot be left
blank
<br>
</div>
</div>
<!-- END SET ONE -->
<div id="set_two" style="background-
color: rgb(176, 229, 124); margin: 10px;">
<span><span style="float: left;">
<label style="width: 85px;
text-align: right; margin-left: 10px;">
<b>Access:</b>&nbsp;
</label>
<label>
Public by default</label>
</span><span style="float: right;
margin-right: 10px;" onclick="expCollapse('set2', 'img2')">
<label style="text-decoration:
underline; color: Blue; cursor: pointer;">
Edit</label>&nbsp;<img
id="img2" src="../icons/btn_down.gif" style="cursor: pointer;" /></
span></span>
<div style="clear: both;">
</div>
<div id="set2" style="margin-left:
10px; display: none;">
<p>
<input class="input"
type="radio" name="public" value="public">
<label>
Public - your video
will be included in search results.
</label>
<br>
<input type="radio"
checked name="unlisted" class="input" value="unlisted">
<label>
Unlisted - your video
will <b>not</b> be included in search results.
</label>
</p>
</div>
</div>
<!-- END SET TW0 -->
<div id="set_three" style="background-
color: rgb(176, 229, 124); margin: 10px;">
<span><span style="float: left;">
<label style="width: 85px;
text-align: right; margin-left: 10px;">
<b>Video Location:</
b>&nbsp;
</label>
<label>
Public by default</label>
</span><span style="float: right;
margin-right: 10px;" onclick="expCollapse('set3', 'img3')">
<label style="text-decoration:
underline; color: Blue; cursor: pointer;">
Edit</label>&nbsp;<img
id="img3" src="http://www.trezoro.com/icons/btn_down.gif"
style="cursor: pointer;" /></span>
</span>
<div style="clear: both;">
</div>
<div id="set3" style="display:
none;">
<p>
<label style="width: 85px;
text-align: right; float: left;">
Address:&nbsp;</label>
<input class="input"
type="text" size="30" name="address">
<input type="button"
onclick="javascript:showAddress(this.form.address.value, 14); return
false;" value="" />

<br />
<br />
<label style="width: 85px;
text-align: right; float: left;">
Location:&nbsp;</
label>
<input type="text"
id="coords" name="coords" size="53" class="input" style="border-
style:none; color:Black; background-color:Transparent;" />
<br />
<br />
</p>
</div>
</div>
<!-- END SET THREE -->
<div id="set_four" style="background-
color: rgb(176, 229, 124); margin: 10px;">
<span><span style="float: left;">
<label style="width: 85px;
text-align: right; margin-left: 10px;">
<b>Privacy:</b>&nbsp;
</label>
<label>
Public by default</label>
</span><span style="float: right;
margin-right: 10px;" onclick="expCollapse('set4', 'img4')">
<label style="text-decoration:
underline; color: Blue; cursor: pointer;">
Edit</label>&nbsp;<img
id="img4" src="../icons/btn_down.gif" style="cursor: pointer;" /></
span>
</span>
<div style="clear: both;">
</div>
<div id="set4" style="margin-left:
10px; display: none;">
<p>
<span style="float:
left;">
<label style="float:
left; margin-left: 10px;">
<b>Comments:</b></
label>
<span style="float:
right; margin-right: 10px; width: 275px;">
<input
type="radio" checked name="comments" class="input">
<label
style="width: 100px;">
Allow all
comments without approval.</label>
<br />
<input
type="radio" name="comments" class="strangers">
<label
style="width: 100px;">
I must approve
comments from strangers.</label>
<br />
<input
type="radio" name="comments" class="input">
<label
style="width: 100px;">
I must approve
all comments.</label>
<br />
<input
type="radio" name="comments" class="input">
<label
style="width: 100px;">
Disable all
comments on this video.</label>
<br />
</span></span><span
style="float: left; margin-top: 10px;">
<label
style="float: left; margin-left: 10px;">
<b>Ratings:</
b></label>
<span
style="float: right; margin-right: 10px; width: 275px;">
<input
type="radio" checked name="ratings" class="input">
<label
style="width: 100px;">
Allow
users to rate this video.</label>
<br />
<input
type="radio" name="ratings" class="input">
<label
style="width: 100px;">
Disable
ratings on this video.</label>
<br />
</span></
span><span style="float: left; margin-top: 10px;">
<label
style="float: left; margin-left: 10px;">

<b>Embedding:</b></label>
<span
style="float: right; margin-right: 10px; width: 275px;">
<input
type="radio" checked name="embedding" class="input">
<label
style="width: 100px;">
Allow
anybody to show this video.</label>
<br />
<input
type="radio" name="embedding" class="input">
<label
style="width: 100px;">
Keep
the video on this site only.</label>
<br />
</span></span>
</p>
</div>
<div style="clear: both;">
</div>
</div>
<div id="set_five" style="background-
color: rgb(176, 229, 124); margin: 10px;">
<span><span style="float: left;">
<label style="width: 85px;
text-align: right; margin-left: 10px;">
<b>Date and Time:</
b>&nbsp;
</label>
<label>
Today by default</label>
</span><span style="float: right;
margin-right: 10px;" onclick="expCollapse('set5', 'img5')">
<label style="text-decoration:
underline; color: Blue; cursor: pointer;">
Edit</label>&nbsp;<img
id="img5" src="../icons/btn_down.gif" style="cursor: pointer;" /></
span></span>
<div style="clear: both;">
</div>
<div id="set5" style="margin-left:
10px; display: none;">
<p>
<label style="width: 85px;
text-align: right; float: left;">
Date:&nbsp;
</label>
<select id="recorded_mo"
name="recorded_mo" class="input">
<option value="0">---</option>
<option value="1">January</
option>
<option value="2">Feburary</
option>

<option value="12">December</option>
</select>
<select id="recorded_day"
name="recorded_day" class="input">
<option value="0">---</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>

<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>

<option value="31">31</option>
</select>
<select id="recorded_yr"
name="recorded_yr" class="input">
<option value="0">---</option>
<option value="2007">2007</
option>
<option value="2006">2006</
option>
<option value="2005">2005</
option>
<option value="2004">2004</
option>
</select>
<input id="today" value="Today"
onclick="todayDate();" type="button">
<input id="reset" value="Reset"
onclick="clearDate();" type="button">
<br />
<br />
<label style="width: 85px; text-
align: right; float: left;">
From:&nbsp;
</label>
<select id="frmtime_hour"
name="frmtime_hour" class="input">
<option value="0">---</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
</select>
<select id="frmtime_minutes"
name="frmtime_minutes" class="input">
<option value="0">---</option>
<option value="1">00</option>
<option value="2">15</option>
<option value="3">30</option>
<option value="4">45</option>
</select>
<select id="frmtime_ampm"
name="frmtime_ampm" class="input">
<option value="0">---</option>
<option value="1">AM</option>
<option value="2">PM</option>
</select>
<br />
<br />

<label style="width: 85px; text-
align: right; float: left;">
To:&nbsp;
</label>
<select id="totime_hour"
name="totime_hour" class="input">
<option value="0">---</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
</select>
<select id="totime_minutes"
name="totime_minutes" class="input">
<option value="0">---</option>
<option value="00">00</option>
<option value="15">15</option>
<option value="30">30</option>
<option value="45">45</option>
</select>
<select id="totime_ampm"
name="totime_ampm" class="input">
<option value="0">---</option>
<option value="1">AM</option>
<option value="2">PM</option>
</select>
<input id="Button1" value="All
Day" onclick="allDay();" type="button">
</p>
</div>
</div>
<div>
<center>
<input type='submit'
id="submitupload" value='Upload Video(s)' name="" />
</center>
</div>
<p>
</p>
</form>


No such luck, huh? Ok, well, thanks for looking.

Cheers!
 
R

RobG

It will help if you read the FAQ and follow the tips there on posting.

<URL: http://www.jibbering.com/faq/ >

[ deleted 574 lines of code ]
No such luck, huh? Ok, well, thanks for looking.

If you want help, post a minimal example that displays your problem,
not 500 lines of code. And when replying, trim quotes to what is
needed, don't needlessly include hundreds of irrelevant lines.
 
P

pbd22

OK, sorry. I posted a minimal amount of code previously but
kept getting asked to provide more code/markup/etc. Anyway,
I'll try again and appreciate your patience.

My problem is with the construction of a function named
activeRow. The function exists inside a MultiSelector class
that serves to allow the user to select and upload multiple
files.

The problem code doesn't throw an error, but it doesn't work
either and I am wondering if I am thinking about the logic
incorrectly.

The part of the function that I am having problems with
is here:


var inputs = new Array();

[SNIP: for loop that collects data inputs]

var fileQueue = new Array(global_cnt);

// Sort through files selected
for (var i=0; i<=global_cnt; i++) {
// If the file was clicked
if (i == uid) {
fileQueue = new Array(inputs.length);
for (var j=0; j < inputs.length; j++)
{
if(fileQueue[j]){
inputs[j].value = fileQueue[j];
}

inputs[j].onclick = function() {
fileQueue[j] = inputs[j].value;
}

}

}

}


The purpose of this code is to go through each input on the form
(inputs.length) that accepts data and store that data for each
selected file (global_cnt is the total files selected for upload and
"uid" is the passed-in parameter signifying the current file's
position (0,1,2,3, etc). This is why I chose a multidimensional array.

Thanks again for your patience. Kindly let me know if you would like
me to add more code/information. Otherwise, thanks for any feedback.

Regards.
 
R

RobG

OK, sorry. I posted a minimal amount of code previously but
kept getting asked to provide more code/markup/etc. Anyway,
I'll try again and appreciate your patience.

My problem is with the construction of a function named
activeRow. The function exists inside a MultiSelector class
that serves to allow the user to select and upload multiple
files.

The problem code doesn't throw an error, but it doesn't work
either and I am wondering if I am thinking about the logic
incorrectly.

The part of the function that I am having problems with
is here:

var inputs = new Array();

[SNIP: for loop that collects data inputs]

var fileQueue = new Array(global_cnt);

There is rarely any point in initialising the length of an array,
consider:

var inputs = [];

// Sort through files selected
for (var i=0; i<=global_cnt; i++) {

I don't know how you set global_cnt (which seems a particularly bad
name for a variable), but I would expect that you should be using:

for (var i=0; i<global_cnt; i++) {

// If the file was clicked
if (i == uid) {
fileQueue = new Array(inputs.length);
for (var j=0; j < inputs.length; j++)
{
if(fileQueue[j]){


Given that fileQueue has just been initialised as an array, it is
certain that fileQueue[j] does not exist and will return
'undefined', which will evaluate to false.

I presume this stems from your initialising the array with a length -
all that does is set the length property to some value that may well
change. Your problems stem from that.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top