473,387 Members | 1,313 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.

items[1][quantity]: "document has no properties"

77
hello all, i have this html below


[HTML]<input type="text" name="items[1][quantity]" size="3" value="1" onchange="javascript:showNameObject();"/>
[/HTML]
and i want to alert that object of name with this script

Expand|Select|Wrap|Line Numbers
  1. <script language="javascript">
  2.  var form = document.forms[0];
  3. function showNameObject() {
  4.      alert(form.items[1][quantity].name);
  5. }
  6. </script>
  7.  
but the browser shown an error "document has no properties..."

any advice please...???thanks
Jul 18 '08 #1
6 2040
dmjpro
2,476 2GB
I think name items[1][quantity] is not valid.
Jul 18 '08 #2
r035198x
13,262 8TB
Why don't you explain what you are trying to achieve first.
Jul 18 '08 #3
maminx
77
Why don't you explain what you are trying to achieve first.
actually i have the function to create an element (input, textarea, and select option)..
and it's generated by looping..of course to make a name and id of that element that i've created is by array..This is the snipped of that function

Expand|Select|Wrap|Line Numbers
  1.     function create_itemized_fields()
  2.     {
  3.         var form = document.forms[0];
  4.         // add a new counter to item_count, which tracks the current number of items.
  5.         item_count++;    
  6.         if (item_count <= <?php echo DetailRowMax?>){//DetailRowMax value could be changed at config.php
  7.             var row = document.createElement('tr');
  8.             row.setAttribute('id', 'item'+item_count);
  9.  
  10.             var td = document.createElement('td');
  11.             var p = document.createElement('p');
  12.             var label = document.createElement('label');
  13.             var span = document.createElement('span');
  14.             var theData = document.createTextNode('Pra BP No.');
  15.             var theInput = document.createElement('input');
  16.             theInput.setAttribute('type', 'text');
  17.             theInput.setAttribute('name', 'items['+item_count+'][quantity]');
  18.             theInput.setAttribute('size', '3');
  19.             theInput.setAttribute('class', 'requiredfield');            
  20.             theInput.setAttribute('value',item_count);
  21.             //theInput.setAttribute('onkeyup', 'recalculate_items();');
  22.             span.appendChild(theData);
  23.             label.appendChild(span);
  24.             label.appendChild(theInput);
  25.             p.appendChild(label);            
  26.             td.appendChild(p);
  27.             row.appendChild(td);
  28.              }else { alert("test");
  29.              }
  30. }
  31.  
  32.  
so, have any idea?
Jul 18 '08 #4
acoder
16,027 Expert Mod 8TB
Please enclose your posted code in [code] tags (See How to Ask a Question).

This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.

Please use [code] tags in future.

Also, remember to provide a meaningful Title for any threads started (see the FAQ entry Use a Good Thread Title).

This helps to ensure that other members, and also the general public, will have a better chance of finding answers to any similar questions.

MODERATOR
Jul 18 '08 #5
acoder
16,027 Expert Mod 8TB
and i want to alert that object of name with this script

Expand|Select|Wrap|Line Numbers
  1. <script language="javascript">
  2.  var form = document.forms[0];
  3. function showNameObject() {
  4.      alert(form.items[1][quantity].name);
  5. }
  6. </script>
  7.  
but the browser shown an error "document has no properties..."
If this is the error, that means the error is on the line before the function: var form=document.forms[0]. The document is not ready. Make sure the line is inside the function or called after the page has loaded.

PS. use the type attribute for the script tag. The language one has been deprecated.

PPS. and yeah, form.items[i][quantity] is incorrect syntax, but we can deal with that later.
Jul 18 '08 #6
maminx
77
If this is the error, that means the error is on the line before the function: var form=document.forms[0]. The document is not ready. Make sure the line is inside the function or called after the page has loaded.

PS. use the type attribute for the script tag. The language one has been deprecated.

PPS. and yeah, form.items[i][quantity] is incorrect syntax, but we can deal with that later.

ok thanks a lot sir

kind regard, mamin
Jul 23 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Mark Hannon | last post by:
I have been researching the "disabled" property for form data and wanted to know: - Does the disabled property supress the form item from being submitted? - Can the disabled property be applied...
14
by: Alf P. Steinbach | last post by:
Not yet perfect, but: http://home.no.net/dubjai/win32cpptut/special/pointers/ch_01.pdf http://home.no.net/dubjai/win32cpptut/special/pointers/ch_01_examples.zip To access the table of...
0
by: VB Newbie | last post by:
I am creating a user control containing a combobox using VB.NET(2003) I want to add 2 public properties "DataSource" and "Items" like the "System.Windows.Forms.ComboBox" here is my code, but it...
5
by: VB Newbie | last post by:
I am creating a user control containing a combobox using VB.NET(2003) I want to add 2 public properties "DataSource" and "Items" like the "System.Windows.Forms.ComboBox" here is my code, but it...
2
by: Emily | last post by:
Hi all, I have the following simplified version of xml file: <xml xmlns:s='uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882'> <s:Schema id='RowsetSchema'> <s:ElementType name='row'>...
1
by: k386 | last post by:
I am having trouble creating a hidden form field, or least having it accessible from getElementById. Rough overview: I am reading an XML file through XMLhttpRequest and outputting each item...
1
by: luispunchy | last post by:
I have an accordion style dropdown list/sublist menu (functions similar to the "today on WebMD video" widget found on http://www.webmd.com/) - it will allow users to click on a headline (from the...
17
by: David C. Ullrich | last post by:
Having a hard time phrasing this in the form of a question... The other day I saw a thread where someone asked about overrideable properties and nobody offered the advice that properties are...
4
by: kimiraikkonen | last post by:
Hi, I have a odd but a known question about listbox. I know listbox control can provide multi-select, multi-extendend selections. But i wonder if this selection type belongs to them or it has...
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.