473,586 Members | 2,682 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

77 New Member
hello all, i have this html below


[HTML]<input type="text" name="items[1][quantity]" size="3" value="1" onchange="javas cript:showNameO bject();"/>
[/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...???tha nks
Jul 18 '08 #1
6 2047
dmjpro
2,476 Top Contributor
I think name items[1][quantity] is not valid.
Jul 18 '08 #2
r035198x
13,262 MVP
Why don't you explain what you are trying to achieve first.
Jul 18 '08 #3
maminx
77 New Member
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 Recognized Expert Moderator MVP
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 Recognized Expert Moderator MVP
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.f orms[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 New Member
If this is the error, that means the error is on the line before the function: var form=document.f orms[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
2466
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 when the submit button is pressed? I am designing a PayPal order page that will have 4 items, each with a 3-character text box where the customer...
14
2817
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 contents, use the "Bookmarks" tab in Adobe Acrobat. Comments, corrections, praise, nits, etc., are still welcome!
0
1462
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 doesn't work. What's wrong with it? Public Property cboDataSource() As Object Get Return Me.cbo.DataSource 'cbo is my combobox End Get
5
6898
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 doesn't work. What's wrong with it? Public Property cboDataSource() As Object Get Return Me.cbo.DataSource 'cbo is my combobox End Get
2
1896
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'> <s:AttributeType name='Fund1'> <s:AttributeType name='Fund2'> <s:AttributeType name='Fund3'>
1
2658
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 into a unique div tag, which has a dynamically generated name, then appending each div tag to an existing div tag. This is working A-OK. Here's the...
1
2658
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 main list) to open up the full listing (sublist) below that headline. My JavaScript is almost but not quite working as needed. It also serves up an...
17
2768
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 Bad. So maybe we've got over that. I suppose properties could have Bad consequences if a user doesn't know they exist and think that a certain...
4
1438
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 another tecnique. As you may know, in softwares like Windows Media Player or Winamp playlist has a listbox and it can be selected in 2 types. First...
0
7912
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7839
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8202
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8338
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
8216
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5710
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5390
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3837
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3865
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.