473,578 Members | 2,739 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

selecting an index

i use this but select the index by name??

document.form1. table_name.sele ctedIndex= 2;
what i want

document.form1. table_name.sele ctedIndex= "news";

Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
------->>>>>>http://www.NewsDemon.c om<<<<<<------
Unlimited Access, Anonymous Accounts, Uncensored Broadband Access
Oct 25 '05 #1
4 1105
Ross wrote:
i use this but select the index by name??

document.form1. table_name.sele ctedIndex= 2;

If this works, then form1 is the name or id of a form, table_name is the
name or id of a select element that is a child of form1 and it has at
least 3 option elements.

The above will select the 3rd option.

what i want

document.form1. table_name.sele ctedIndex= "news";

If the above is correct, you can't do it. An option element can't have
a name attribute, though it can have an ID.

If what you want to do is select the option with either text or value of
'news', then loop through the elements looking for the right one. Once
you find it, set it to selected. Something like:
var opts = document.form1. table_name.opti ons;
for (var i=0, len=opts.length ; i<len; ++i){
if ('news' == opts[i].value){
opts[i].selected = true;
// Just in case none match?
opts[0].selected = true;
If you want to match the text content, then use:

if ('news' == opt[i].text){


Oct 25 '05 #2

Ross wrote:
i use this but select the index by name??

document.form1. table_name.sele ctedIndex= 2;
what i want

document.form1. table_name.sele ctedIndex= "news";

<option selected value="news">Re cent News</option>

1. document.form1. table_name[form1.table_nam e.selectedIndex].text='Hot

(Changes "Recent News" to "Hot News")

document.form1. table_name[form1.table_nam e.selectedIndex].value='hot_new s';

(Changes "news" to "hot_news")

Oct 25 '05 #3
Seems I did not get your problem right.

Oct 25 '05 #4
VK wrote on 25 okt 2005 in comp.lang.javas cript:
Seems I did not get your problem right.

But I have no problem.

[please always quote on usenet, this is not email]

The Netherlands.
(Replace all crosses with dots in my emailaddress)

Oct 25 '05 #5

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

Similar topics

by: Axial | last post by:
Question: How to select columns from Excel-generated XML when some cells are empty. I've found examples where rows are to be selected, but I can't seem to extrapolate from that to selecting columns when some cells are empty. Is there a way to use the ss:Index to account for the missing <Cell elements? Thank you for any suggestions. ...
by: booner | last post by:
I have a form that when it loads I would like to highlight the values (from a DB) that have been selected in a multiple selection list (<select multiple="true">. function onLoad() { document.forms.elements.value = "<value from DB>"; }
by: don | last post by:
Ref Dvd Title Location ---------------------------------------- 62 Pilates; Austin Binder 1 63 Yoga; Kripalu Binder 1 64 Yoga; Workout Binder 1 93 The Sopranos Binder 1 94 The Sopranos Binder 2 95 The Sopranos Binder 3
by: Phil Powell | last post by:
I am producing a form using PHP on the back end and Javascript on the front end. The resulting script will come to the browser as follows: <script> <!-- function selectAll() { moveElement = eval("document.imageForm.move" + ""); alert(moveElement); if (document.imageForm.select_all.checked) {
by: Ramesh | last post by:
hi, I am selecting fields from three table for manupulating data and i want to display total number of records selected. But i am always getting -1 value, eventhough 1000 of records are selected. Below is my code. here strSelectSQL value is strSelectSQL = "Select emp.Empno, emp.FirstName, emp.LastName, emp.DB,...
by: Ron | last post by:
I've got a listbox that holds a list of groups. Users can select a group, hit the remove button and the group should be removed from the listbox. The only problem is that no matter which group you select, the first one in the listbox is always removed.(The listitem with an index of 0. Box is set to single selection mode) I've looked at...
by: Kari Lavikka | last post by:
Hi! I have to select a random row from a table where primary key isn't continuous (some rows have been deleted). Postgres just seems to do something strange with my method. -- -- Use the order by desc limit 1 -trick to get maximum value -- CREATE OR REPLACE FUNCTION max_uid() RETURNS int4 AS
by: Miquel van Smoorenburg | last post by:
I have a database with a btree index on the 'removed' field, which is of type 'date'. However it isn't being used: techdb2=> explain select * from lines where removed > CURRENT_DATE; QUERY PLAN ------------------------------------------------------------ Seq Scan on lines (cost=0.00..243.47 rows=2189 width=324) Filter: (removed >...
by: joshsackett | last post by:
I am having a problem with indexes on specific tables. For some reason a query that runs against a view is not selecting the correct index on a table. I run the same query against the table directly and it looks fine. Can anyone give me some insight? Thanks. PRODUCTION1: CREATE TABLE MyTest1 (ID INT IDENTITY(1,1), COLUMN1 CHAR(10), COLUMN2...
by: lane straatman | last post by:
I'm trying to figure out what data type is appropriate to represent a card in a game. The idea that I thought was going to work was a struct, foo, with two integer fields and two fields of char arrays: index cardno description suit ( 1, 1,Two of clubs ,'c') ( 2, 2,Three of clubs ,'c') ( 3, 3,Four of...
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...
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...
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...
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...
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...
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...
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
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.