Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Text Input Array, Altering styles
Old 03-15-2011, 12:13 PM Text Input Array, Altering styles
Extreme Talker

Posts: 177
Trades: 0
Say I have something like this:

Code:
<form name="form1" method="POST" action="action.php">
<input type="text" name="golf_tees[]" id="golf_tees[]">
 <input type="text" name="golf_tees[]" id="golf_tees[]">
<input type="text" name="golf_tees[]" id="golf_tees[]">
<input type="text" name="golf_tees[]" id="golf_tees[]">
</form>
If I want to disable the first 2 golf_tees text inputs, how do I go about that? document.getElementById only alters the first input.

Last edited by kbfirebreather; 03-15-2011 at 12:32 PM..
kbfirebreather is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 03-15-2011, 01:16 PM Re: Text Input Array, Altering styles
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,383
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
IDs have to be unique in the document.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 03-15-2011, 01:41 PM Re: Text Input Array, Altering styles
Extreme Talker

Posts: 177
Trades: 0
Quote:
Originally Posted by chrishirst View Post
IDs have to be unique in the document.
If I use document.forms['form1'].elements[], is there any way of doing that?
kbfirebreather is offline
Reply With Quote
View Public Profile
 
Old 03-15-2011, 04:10 PM Re: Text Input Array, Altering styles
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,383
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
loop through the elements collection and set the disabled attribute
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 03-17-2011, 03:39 AM Re: Text Input Array, Altering styles
phpdasan's Avatar
Experienced Talker

Posts: 37
Name: Karthick B
Trades: 0
A basic javascript code would be

HTML Code:
var ele = document.forms['form1'].elements;
    for(i = 0;i<ele.length;i++)
    {
        if(ele[i].type == 'text')
        {
            ele[i].disabled = true;
            if(i > 0) break;
        }
    }
__________________
There is no secret ingredient.
phpdasan is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Text Input Array, Altering styles
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.15913 seconds with 12 queries