Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...What a great service! This is the best site I've ever seen!!! It totally restores my faith in humanity when people take time out to help other people..."

Geography

Where in the world do Tek-Tips members come from?

I added another select or dropdown

wudang26 (TechnicalUser)
7 Aug 12 22:16
I added another select or dropdown to my datagrid. Since Im doing this and im using getElementByTagName. I get errors since I have 2 dropdowns in my grid. So im trying to toggle the dropdown to display then hide.


function OnChange(down)
{
var flag = true;

var dropdowns = new Array(); //Create array to hold all the dropdown lists.
// var credit = new Arry();

var gridview = document.getElementById('<%=myDataGrid.ClientID %>'); //GridView1 is the id of ur gridview.

dropdowns = gridview.getElementsByTagName('select'); //Get all dropdown lists contained in GridView1.

for (var i = 0; i < dropdowns.length; i++)
{

if (dropdowns.item(i).value == '2') //If dropdown has no selected value
{
// down.parentElement.nextSibling.children[9].style.display = dis;
var txtshow = new Array();
txtshow = gridview.getElementsByTagName('input');
txtshow.item(i).style.display = 'block';
flag = false;
}

else
{

var txtshow = new Array();
txtshow = gridview.getElementsByTagName('input');
txtshow.item(i).style.display = 'none';
}

if (dropdowns.item(i).value == '1')
{
var txtDrop = new Array();
txtDrop = gridview.getElementsByTagName('label');
txtDrop.item(i).style.display = 'block';
}
else
{
var txtDrop = new Array();
txtDrop = gridview.getElementsByTagName('label');
txtDrop.item(i).style.display = 'none';
}

if (dropdowns.item(i).value == '3') -ERROR STARTS HERE
{
var txtOption = new Array();
txtOption = gridview.getElementsByTagName('select');
txtOption.item(i).style.display = 'block';
}
else
{
var txtOption = new Array();
txtOption = gridview.getElementsByTagName('select');
txtOption.item(i).style.display = 'none';
}


}
return flag;
}
//-->
</script>

<asp:DropDownList ID="DropDownList1" runat="server" onchange="javascript:OnChange(this);" Enabled="True">
<asp:ListItem Value ="0" >Select an Action</asp:ListItem>
<asp:ListItem Value ="1" >Drop</asp:ListItem>
<asp:ListItem Value ="2" >Change</asp:ListItem>
<asp:ListItem Value ="3" >Option</asp:ListItem>
</asp:DropDownList>
</ItemTemplate></asp:TemplateColumn>


This is in another column in the datagrid. This is the dropdown I want to toggle display.

<asp:TemplateColumn HeaderText="Option" Visible="true">

<ItemTemplate>
<select id="Select1" name="option">
<option>U</option>
<option>R</option>
<option>P</option>
<option>S</option> </select>
</ItemTemplate>
</asp:TemplateColumn>
ChrisHirst (IS/IT--Management)
8 Aug 12 6:50
And the errors are???

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum

wudang26 (TechnicalUser)
8 Aug 12 9:14
There's no error. It does not work correctly. It gets the wrong select in the datagrid and makes it invisible since Im using "getElementTagName". Not sure how to fix this.
ChrisHirst (IS/IT--Management)
9 Aug 12 8:41
Give the element you want to target a unique ID.

And: Seeing REAL HTML code would be more use than unrendered .NET code is.

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Back To Forum

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close