473,387 Members | 1,440 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How can I select the content of select tag if the values are viewed by JavaScript?

Exequiel
288 256MB
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <title>Untitled Document</title>
  4. <script type="text/javascript">
  5. function ikel()
  6. {
  7.     var sel = document.ikki.sel.value;
  8.  
  9.     if(sel=="T-shirt")
  10.     {         
  11.         var shirt = ["bench","cotton republic"];
  12.         var shirt_len=shirt.length;
  13.         var el=0;
  14.         for(var ii=0; ii<shirt_len; ii++)
  15.         {
  16.              document.ikki.brand.options[ii]=new Option(shirt[ii], ii);            
  17.             }
  18.         return sel;
  19.     }//end of if satatement T-shirt
  20.  
  21.     if(sel=="CARS")
  22.     {         
  23.         var car = ["Toyota","Honda", "Forbes", "Mitsubishi", "Kia", "Nissan"];
  24.         var car_len=car.length;
  25.         var cc=0;
  26.         for(var cc=0; cc<car_len; cc++)
  27.         {
  28.              document.ikki.brand.options[cc]=new Option(car[cc], cc);            
  29.             }
  30.          return sel;
  31.     }//end of if satatement Cars
  32.  
  33.     if(sel=="Porn Site")
  34.     {         
  35.         var por = ["Mofos.com","Naughty America.com", "Erotica.com"];
  36.         var por_len=por.length;
  37.         var xx=0;
  38.         for(var xx=0; xx<por_len; xx++)
  39.         {
  40.              document.ikki.brand.options[xx]=new Option(por[xx], xx);            
  41.             }
  42.         return sel; 
  43.     }//end of if satatement Cars
  44.  
  45. }//end of function ikel
  46. window.onload=ikel;
  47. </script>
  48. </head>
  49. <body>
  50. <form name="ikki">
  51. Menu
  52.         <select name="sel"  onclick="ikel()" id="selected" >
  53.                    <option >T-shirt</option>
  54.                    <option >CARS</option>
  55.                    <option >Porn Site</option> 
  56.              </select> 
  57.           Brand              
  58.               <select name="brand" onchange="ikel()" ><!--option output--></select> 
  59. </form>
  60. </body>
  61. </html>
I have A question... How can I select the content of brand here...Example : when I selected in the Menu like for Example CARS, the Options will display in "Brand", but when I started to select the 2nd to the last option in Brand, the only value that appears is the first value like "Toyota"...
Jul 12 '12 #1
0 1363

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

Similar topics

2
by: y2rottem | last post by:
Hi all, I am trying, to use form fields and a Master page: I have a form built within the <asp:contentpage>. trying to read its fields using JavaScript I get errors.viewing the generated html...
34
by: kpg | last post by:
Hello all, I have an asp.net web application with tons of Java script files. I would like to protect the Java Script somehow so it can't be seen by a remote user. I found several 3rd party...
7
by: dbabin | last post by:
I have a java script function enableServerList() {document.getElementById("ddlServers").disabled=false } function disableServerList() {document.getElementById("ddlServers").disabled=true } ...
8
by: dbaplusplus | last post by:
I worked on web development using java script many many years, so I am now a newbie to javascript. I have a single html page, which is generated dynamically using some programming language. Web...
15
by: webstormcomputers | last post by:
I'm trying to update a hidden field with java script and I'm only getting one of the values from my select stament. Here is the code below. <select name="on0"> <option value="25">25 <option...
3
by: Tenacious | last post by:
I find that I can call a function in my code behind file from Java Script on the aspx page using this syntax: Lat = <%= GetNextLatitude()%> The function has to be static. No problem so far. When...
1
by: anilkumar1980 | last post by:
Hi All, Here I need help to all of u, I am using ASP.NET 2.0 and Third party Infragistic Controls. I Have included master page in my page (<%@ Page Language="VB"...
2
by: abhishekbrave | last post by:
Hi I have a combo box having the values of year. <select name=year value=2008> <option value=2007>2007</option> <option value=2007>2006</option> <option value=2007>2005</option> </select>& I...
3
by: alandiit | last post by:
Hi every body I would like connect three combo box (CascadingDropDown with a Database) MYSQL by asp classic or Java Script . But I have a problem with this example , when I will change City ,...
7
by: ghjk | last post by:
I have table which is clickable.When user click one record I want to call java script function and fill the form using selected values. This is my code and I can't understand what is going...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...

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.