473,791 Members | 3,074 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

getAttribute of value from drop down list

77 New Member
I have this script...
Expand|Select|Wrap|Line Numbers
  1.         var td = document.createElement('td');
  2.     var p = document.createElement('p');
  3.     var label = document.createElement('label');
  4.     var span = document.createElement('span');
  5.     var theData = document.createTextNode('Chart Of Account');
  6.     var theSelect = document.createElement('select');
  7.     theSelect.setAttribute('name', 'items['+item_count+'][pbdccoa]');
  8.     var opCol = document.createElement('option');
  9.     opCol.setAttribute('value', '');
  10.     var opColTxt = document.createTextNode('<?php echo $this->lang->line('select_coa')?>');
  11.     opCol.appendChild(opColTxt);
  12.     theSelect.appendChild(opCol);
  13.     <?php foreach($coa_list->result() as $coa): ?>                            var opCol = document.createElement('option');
  14.     opCol.setAttribute('value', '<?php echo $coa->ccbcCoa?>');
  15.     var opColTxt = document.createTextNode('<?php echo $coa->ccbcCoa?>');
  16.     opCol.appendChild(opColTxt);
  17.     theSelect.appendChild(opCol);            
  18.     <?php endforeach; ?>
  19.     opCol.onselect = function(){
  20.     if (this.getAttribute('value')==null || this.getAttribute('value')==""){
  21.         alert("Require field");
  22.         }
  23.     }
  24.     span.appendChild(theData);
  25.     label.appendChild(span);
  26.     label.appendChild(theSelect);
  27.     p.appendChild(label);
  28.     td.appendChild(p);
  29.     row.appendChild(td);
  30.  
With this command below i want to check the value of drop down list, if user select a null value of drop down list, than it will show an alert window ("Require Field").

Expand|Select|Wrap|Line Numbers
  1. if (this.getAttribute('value')==null || this.getAttribute('value')==""){
  2.         alert("Require field");
  3.         }
  4. }
  5.  

But it doesn;t work well, any idea??thanks for helping me..
Jul 15 '08 #1
3 2559
rnd me
427 Recognized Expert Contributor
xbrowser onchange:

Expand|Select|Wrap|Line Numbers
  1. <select onchange"var ti=this.selectedIndex;var op=this.options; if(op[ti].value){ alert(op[ti].value); }">
Jul 15 '08 #2
maminx
77 New Member
xbrowser onchange:

Expand|Select|Wrap|Line Numbers
  1. <select onchange"var ti=this.selectedIndex;var op=this.options; if(op[ti].value){ alert(op[ti].value); }">

sorry i dont understand with that, where do i must put that script??
thanks
Jul 17 '08 #3
acoder
16,027 Recognized Expert Moderator MVP
onselect is only for text inputs and textareas. Use onchange on the select element, e.g.
Expand|Select|Wrap|Line Numbers
  1. theSelect.onchange = function() {
  2.     if (this.value == "") alert("Required Field");
  3. }
Jul 17 '08 #4

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

Similar topics

1
2913
by: Dan | last post by:
This is one that has me stumped and I need an expert's input. Any ideas why the values from the second script-generated drop down list isn't recognized by the script to add time values to the text boxes? What this script is suppose to do is change the value of a second drop down list based on the selection from the first. Then a value is chosen from the script generated drop down list in the
3
2479
by: pmud | last post by:
Hi, I have a drop down list bound to a database thorugh a data reader. It reads the customer names from data reader. Now, I want the user to be able to type more than one alphabet & the list becomes shorter & shorter for the user to choose a value from. For example, suppose the user wants to select the name "Michael" from the dop down list . So when he tabs over & reaches this drop down list, he types "Mi" , then all the names...
4
2107
by: Martyn Fewtrell | last post by:
I want to update a database record with a number of fields - doesn't sound to difficult at this stage! I have a system to select the correct record from the database and load the data into a form across a number of text boxes and a single drop down list (the idea being that the text boxes can be edited and the drop down listed altered to reflect a new value if necessary). The drop down list in the form is loaded from the appropriate...
3
12488
by: Mike Collins | last post by:
I'm not feeling too smart right now, but I cannot get the correct drop down list value from a drop down I have on my web form. I get the initial value that was loaded in the list. Can someone show me what I am doing wrong and tell me the correct way? Thank you. In the page load event, I am doing the following: //Code I use to populate the dropdown list. ddAssignedTo.DataValueField = "PersonnelID"; ddAssignedTo.DataTextField =...
2
4558
by: Mike Collins | last post by:
I cannot get the correct drop down list value from a drop down I have on my web form. I get the initial value that was loaded in the list. It was asked by someone else what the autopostback was set to...it is set to false. Can someone show me what I am doing wrong and tell me the correct way? Thank you. In the page load event, I am doing the following:
2
4561
by: Ren | last post by:
Hi all, I am a bit new to PHP and SQL so this may seem like a dumb question. I have already created a drop down list as part of a form which is automatically populated with values taken from a separate database. When a user goes onto this page and either leaves the default value or selects a value from the drop down list and presses the submit button, I would like that selected value to be stored into a database which I have already...
0
2166
by: weiwei | last post by:
Hi here is my scenario, I create a drop down list in itemtemplate.(that drop down is created from db), after user click edit command, my ideal plan is have another drop down list in edititemtemplate with preselected value from the previous drop down list, so far I can only achieved with the regular drop down list in edititemtemplate with no preselected value from previous one. anyone can help me. thanks in advance. below is my current...
3
7361
by: penny111 | last post by:
Hi there, For my application, i need to have 3 drop down lists 1. drop down list of folder names 2. drop down list of documents in the folder selected 3. drop down list of instances of the document selected (my application uses the BusinessObjects Java Web Services SDK) The 2nd list is dependent on the 1st, while the 3rd list is dependent on the 2nd. In other words, this is what i want my application to do -select a folder from the...
2
2015
by: axapta | last post by:
Hi Group, How can I limit a second drop-down list box based on a selected value in the first drop down list box. Using vb.net Regards
0
9669
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10428
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10207
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10156
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9997
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9030
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5559
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4110
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3718
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.