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

Another problem involving format-for-PHP Javascript functions and form elements

Expand|Select|Wrap|Line Numbers
  1. function populateWithPics(folder) {
  2. if (folder.value != '') {
  3. monthIndex = folder.name.substring(folder.name.indexOf("'") + 1,
  4. folder.name.indexOf('\]') - 1);
  5. indexArray = folder.value.split('|');
  6. index = indexArray[0];
  7. if (!isNaN(index)) {
  8. for (i = 0; i < picsArray[index].length; i++) {
  9. document.calendarPicForm.elements['pics\[' + monthIndex +
  10. '\]'].options[i + 2].value = picsArray[index][i];
  11. document.calendarPicForm.elements['pics\[' + monthIndex +
  12. '\]'].options[i + 2].text = picsArray[index][i];
  13. }
  14. }
  15. }
  16. }
  17.  
The preceeding code is going to populate a dropdown named pics['0'] or
pics['5'] or pics['digit between 0 and 11'] with contents found in
picsArray[0] or picsArray[5], etc.

However upon attempt to do so I am getting the following error:

"document.calendarPicForm.elements['....'] is null or not an object"

Here is the script for the dropdown (an example, since there are 12 of
them to choose from):

Expand|Select|Wrap|Line Numbers
  1. <select name=pics[2]>
  2. <option value="">
  3. Choose a picture to display for the month of Mars:
  4. </option>
  5. <option value="">-------------------------------------------</option>
  6. </select>
  7.  
And picsArray is a 2-dim TCL-generated server-side array:

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2. <!--
  3. picsArray[0] = new Array(7);
  4.  
  5. picsArray[0][0] = '/images/bands/Crimson_Moonlight.jpg';
  6.  
  7. picsArray[0][1] = '/images/bands/Crimson_Thorn.jpg';
  8.  
  9. picsArray[0][2] = '/images/bands/Extol.JPG';
  10.  
  11. picsArray[0][3] = '/images/bands/Lengsel.jpg';
  12.  
  13. picsArray[0][4] = '/images/bands/Vaakevandring.jpg';
  14.  
  15. picsArray[0][5] = '/images/bands/Zane_Matthews_04.jpg';
  16.  
  17. picsArray[0][6] = '/images/bands/vaakevandring2.jpg';
  18.  
  19. //-->
  20. </script>
  21.  
Bottom line: I want to populate a corresponding dropdown with a
corresponding 2-dim array upon selecting something from one of 12
dropdowns. The function fails due to the structure of of the form
element, so I am not sure what to do at this point, so I need help
again.

Thanx
Phil
Jul 23 '05 #1
1 1147
On 18 Apr 2004 20:40:00 -0700, Phil Powell <so*****@erols.com> wrote:

[snip]
The preceeding code is going to populate a dropdown named pics['0'] or
pics['5'] or pics['digit between 0 and 11'] with contents found in
picsArray[0] or picsArray[5], etc.

However upon attempt to do so I am getting the following error:

"document.calendarPicForm.elements['....'] is null or not an object"

Here is the script for the dropdown (an example, since there are 12 of
them to choose from):

[code]
<select name=pics[2]>
This is most likely to be the source of the problem. Only a combination of
letters, numbers, colons (:), underscores (_), periods (.), and hyphens
(-). Any other character requires the entire attribute value to be quoted.
I expect that if you check the document tree, that SELECT element has a
name attribute of "pics".

[snip]
<script type="text/javascript">
<!--
Hiding scripts is an obsolete practice. Remove the SGML comment delimiters.
picsArray[0] = new Array(7);

picsArray[0][0] = '/images/bands/Crimson_Moonlight.jpg';

picsArray[0][1] = '/images/bands/Crimson_Thorn.jpg';

picsArray[0][2] = '/images/bands/Extol.JPG';

picsArray[0][3] = '/images/bands/Lengsel.jpg';

picsArray[0][4] = '/images/bands/Vaakevandring.jpg';

picsArray[0][5] = '/images/bands/Zane_Matthews_04.jpg';

picsArray[0][6] = '/images/bands/vaakevandring2.jpg';


[snip]

Look into using array literals. You could write the above with

picsArray = [
[ '/images/bands/Crimson_Moonlight.jpg',
'/images/bands/Crimson_Thorn.jpg',
'/images/bands/Extol.JPG',
'/images/bands/Lengsel.jpg',
'/images/bands/Vaakevandring.jpg',
'/images/bands/Zane_Matthews_04.jpg',
'/images/bands/vaakevandring2.jpg' ],
[ /* picsArray[ 1 ] */ ]];

Hope that helps,
Mike

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 23 '05 #2

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

Similar topics

2
by: cschang | last post by:
One of my client stations using IE 6 (v6.0.2800) to open one of my page which write the records into an excel format. However, it got some strange pop-up message that I can not figure out where it...
3
by: darkstorm | last post by:
I have a doubt regarding inheritance involving templates Consider this: ///////////////////////////////////// template<typename T> class A { private: T m_a;
11
by: ned786 | last post by:
Hello, I'm trying to solve an XSLT problem, and I'm hoping someone can give a little guidance. I am transforming XML to HTML. Here's an example of the XML file I'm dealing with, greatly...
2
by: Tobias Olbort | last post by:
Hello, i've a outer function, which takes a params-array as a parameter. I want to pass this array to inner function with a params-array (e. g. string.format). When i've passed an integer to...
2
by: Zeb Davis | last post by:
Hello Newsgroup I'm new in C#, and I was wanting to create a console application involving generating 100 random numbers between 0 and 1000. After running that method, I want to write a method...
1
by: Starbuck | last post by:
Hi Simply because the challenge is there I am trying to convert my vb6 code to vb.net. In the most part I have found ways but here is one I am stuck on, so any thoughts would be welcome. ...
9
by: Yeah | last post by:
I have web document A which contains six links that all go to document B. However, all hyperlinks must go to a different location within that document (similar to anchors: A NAME= etc.). How do...
5
by: coltrane | last post by:
Is it possible to have a function with variable number of parameters pass the parameters to another method that takes variable number of params? maybe something like this void vfoo2( const...
5
stonward
by: stonward | last post by:
Hi Folks, This one is from work! Running Access 07, usually our default saving format is 2003 - not our fault. I want to publish a database to our SharePoint system, but the database must be...
8
by: perlprogrammer | last post by:
Hi, i would like to transform xml to another format (in doing so i loose the orignal xml format). Again i would like transform to the original XML format. is there a way to save the xml...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: 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
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.