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

Need Help with my script logic

Hi.

In my script the below code creates a new element
on the page with an associated delete button:

var row_element = new Element(
'div',
{
'class':'container',
'events':{
'click':function( uid ){
this.activeRow( uid );
}.pass( current_element.uid, this )
}
}
).adopt( delete_button ).adopt( item );

Now, when a user clicks on that element, I want the
input fields on the page to be particular to that element.
So, whatever is written in them, gets stored in an array
that is specific to this particular element "uid". If something
was written, the fields get repopulated when the element
is clicked on again.

Here is the function that gets activated when the element is clicked
on:

activeRow:function( uid ){

active_row = this.elements[ this.uid_lookup[ uid ] ];
[?]

}

I am not quite sure how to approach this, help appreciated.

Thanks.

Sep 24 '07 #1
4 1297
On Sep 24, 2:36 pm, pbd22 <dush...@gmail.comwrote:
Hi.

In my script the below code creates a new element
on the page with an associated delete button:

var row_element = new Element(
'div',
{
'class':'container',
'events':{
'click':function( uid ){
this.activeRow( uid );
}.pass( current_element.uid, this )
}
}
).adopt( delete_button ).adopt( item );

Now, when a user clicks on that element, I want the
input fields on the page to be particular to that element.
So, whatever is written in them, gets stored in an array
that is specific to this particular element "uid". If something
was written, the fields get repopulated when the element
is clicked on again.

Here is the function that gets activated when the element is clicked
on:

activeRow:function( uid ){

active_row = this.elements[ this.uid_lookup[ uid ] ];
[?]

}

I am not quite sure how to approach this, help appreciated.

Thanks.
OK, I think I have figured out a more productive way to ask this
question (i hope). Could somebody show me how I could identify a
change on my form (select box, input field, textarea, etc) and assign
the new values to an associated array for each element. So, there will
be a selectbox[0], input[0], etc and selectbox[1], input[1], etc. My
attempts at this have been pretty ugly - lots of code.

Thanks for any help.

Sep 25 '07 #2
pbd22 wrote:
>
OK, I think I have figured out a more productive way to ask this
question (i hope). Could somebody show me how I could identify a
change on my form (select box, input field, textarea, etc) and assign
the new values to an associated array for each element. So, there will
be a selectbox[0], input[0], etc and selectbox[1], input[1], etc. My
attempts at this have been pretty ugly - lots of code.

Thanks for any help.
Well, if it works, does it matter if it's one or three lines of code? It
really shouldn't, especially if it makes for readable/maintainable code.

Maybe you should post the code that does work, so someone can help you
beautify/optimize it.
--
Sabine Dinis Blochberger

Op3racional
www.op3racional.eu
Sep 25 '07 #3
On Sep 24, 10:36 pm, pbd22 <dush...@gmail.comwrote:
In my script the below code creates a new element
The code below uses what must be a function named "Element" to create
a javascript object, though the fate of that object is unclear form
the code. If here you are referring to a DOM node implementing the
Element interface being created as a side effect (or anything else)
there is no evidence of that happening in this code.
on the page with an associated delete button:

var row_element = new Element(
'div',
{
'class':'container',
'events':{
'click':function( uid ){
this.activeRow( uid );
}.pass( current_element.uid, this )
}
}
).adopt( delete_button ).adopt( item );

Now, when a user clicks on that element,
Which element? You can "click on" (at least most) DOM Elements, but
"clicking" is a little detached from being something that you can do
with a javascript object.
I want the input fields on the page
What input fields, what page?
to be particular to that element.
So, whatever is written in them, gets stored in an array
that is specific to this particular element "uid". If something
was written, the fields get repopulated when the element
is clicked on again.
That sounds more like you want the contents of an INPUT (presumably
type="text") Element to change when some notion of 'current selection'
is applied to one of some group of other Elements by the action of
clicking.
Here is the function that gets activated when the element is clicked
on:

activeRow:function( uid ){

active_row = this.elements[ this.uid_lookup[ uid ] ];
[?]

}
How does it "get activated"? As javascript determines the - this -
value by how a function is called that is very important in
determining how this might behave, or be written so that it does
something related to what you are interested in.
I am not quite sure how to approach this, help appreciated.
The best approach to getting a question answered is to provide the
information necessary to answer it (and not hide it in anything
superfluous). Here you have provided none of the mark-up with which
this code is going to interact, you have not shown the context in
which the first code snippet is executed, your have not shown the
context in which the second is defined, you have not provided the
definition of the - Element - constructor used here, the - adopt -
method or the constructed/returned object (or the - adopt - method of
the object returned from the first call to - adopt -(if they differ)),
the - pass - method that appears to have been added to the -
Function.prototype -, or any of the code that these may depend upon.
There is no indication of the type or nature of the - uid - value or
the - current_element - value.

Sep 25 '07 #4
On Sep 25, 9:47 am, Henry <rcornf...@raindrop.co.ukwrote:
On Sep 25, 2:01 pm, pbd22 wrote:On Sep 25, 4:03 am, pbd22 wrote:
<snip>
Henry, in response to your comments about not having enough
info. Below is the complete script (minus the delete function).

<snip>
You have omitted any code for the constructors - Class - and - Element
below is the script for construction:

<script type="text/javascript">
window.addEvent('domready', function() {
new MultiUpload( $
( 'uploadForm' ).my_file_input_element, 0, '{id}', true, true );
});
</script>
-, their method definitions, some functions (the unwisely named - $ -
and - $defined - functions), at least two - Function.prototype -
extensions, and the code that any of this absent code depends upon,
I am using a javascript library for this. I have no actual prototype
declarations of my own. For the library function definitions, you will
need to look at: http://docs.mootools.net
context of how the code you have posted is executed/used.
Please see the steps marked by an "x" earlier in the thread. The
larger picture is that this is a file upload form and that I am trying
to upload multiple files at the same time using the code I have
posted. The files will all then be sent to the server in succession
for processing. Where I am getting stuck is that, for each file, the
data associated with its form elements need to be saved prior to
submit. I am working on the solution in the activeRow:function() block
that I have posted.
the mark-up that this code is intend to interact with and any
the hidden inputs get populated after the following on the form:

<input id="my_file_input_element" type="file" name="file_1" />

the other relevant fields are pretty much everything that takes data
on the form - selects, inputs, textarea, radiobuttons, etc.

Rather than dump a ton of HTML here - I have named every relevant form
element name="ff1", name="ff2", name="ff3"... name=ffn", where "n" is
the count of the final element. This way I can loop through them if
need be.

Sep 25 '07 #5

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

Similar topics

4
by: nc | last post by:
My iterator can find my collection when my Action class calls my jsp directly, however when my Action class calls an html file that is set up with IFrames (one of which is loading that same jsp), I...
2
by: Matt | last post by:
I know we can write ASP with VB Script. Some people told me the big ASP projects usually use Visual Basic for the business logic. Is that the case? What I mean is an ASP project is the combination...
8
by: Johnny Knoxville | last post by:
I've added a favicon to my site (http://lazyape.filetap.com/) which works fine if you add the site to favourites the normal way, but I have some JavaScript code on a couple of pages with a link,...
8
by: Tom | last post by:
Please help. I need a quick little scrpit to place on a web page that will count how many days have passed since January 1, 1970. I have ZERO experience writing ANY scripts. Anyone have any...
1
by: D. Shane Fowlkes | last post by:
I'm a fairly skilled traditional ASP/VB programmer and am learning .NET. I was (recently) surprised to read in a book about declaring and defining all my page Functions in <script...
4
by: Bob T | last post by:
Hi All, I am trying to pass a variable from my VB asp.net script (from for example Sub Page_Load in mypage.aspx.vb) to my Client side script. I have found and looked at a very good example...
3
by: Mike | last post by:
Hi, I am trying to resize a HTML table through Javascript. When the user control loads the first time, the table is resized, but then it doesn't anymore. I am using the following code in the...
2
by: ern | last post by:
My command-line application must be able to run text scripts (macros). The scripts have commands, comments, and flags. Comments are ignored (maybe they are any line beginning with " ; ") Commands...
1
by: jonathan184 | last post by:
how to monitor and find out if files test1_* and test2_* files were sent in an hour and if not send an email This is on a unix system basically I got a cronjob that runs every sec polling a ftp dir...
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.