Solved

select list

Posted on 2000-03-01
3
148 Views
Last Modified: 2010-04-09
hi...
this is my simple select list:

<html>
<body>
<form>
<select name="cars">
<OPTION SELECTED VALUE="">choose car
<option value="1">honda</option>
<option value="2">peugeot</option>
</select>
</body>
</html>


my quetion: is there any option that if a user going to enter the page,
he will see one of the items and not the "choose car"?
i mean...in text filed i have the value that let me insert any string i want.
is there any way to do it in select list?
i want him to show him for example the "peugeot" option...
(that's call dynamic select list)
elad
0
Comment
Question by:eladr
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 8

Accepted Solution

by:
xabi earned 50 total points
ID: 2572180
Hi there:
I'm not sure about what you want to do  but I will try to explain yo a few things:
The option showed by default is the first one of the list if you don't add the word "selected" in any other option.
ie:
<OPTION VALUE="">choose car
<option value="1">honda</option>
<option value="2" selected>peugeot</option>

this will show peugeot by default.
If you want to do it dinamicaly you must use ASP or PHP or any other language that reads from the database and write the word "selected" in the right option field.

If you need more help just ask

xabi
0
 
LVL 8

Expert Comment

by:xabi
ID: 2572188
You can also change the selected option using javascript.
ie:

..
..
<script language="javascript">
<!--
function init() {
  document.myform.cars.selectedIndex = 2
}
//-->
</script>
</head>
<body onload="init()">
..
..
<form name="myform">
 <select name="cars">
  <option selected value="">choose car</option>
  <option value="1">honda</option>
  <option value="2">peugeot</option>
 </select>
</form>
..
..

This example will select the 3th (0,1,2) option after the page was loaded.

xabi
0
 
LVL 1

Author Comment

by:eladr
ID: 2572231
thanx a lot!
i asked that because i will use it
with asp - you are good!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Responsive Font Size 6 48
Date on a table 16 35
I need to make my existing Javascript Menu conditional within my ASP.Net/C# Application 32 37
HTML editor custom button 3 59
This article discusses four methods for overlaying images in a container on a web page
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question