473,379 Members | 1,243 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,379 software developers and data experts.

Selecting and item in a dropdown box

Let's assume I have a website with a dropdown box on it. there are 3 items in it;

1 - red
2 - blue
3 - green

Is there a javascript function that I could run make the selected item change to a certain item?

Psuedocode:
javascript:document.form[0].element[0].select[green]
or
javascript:document.form[0].element[0].select[3rdItem]

not sure if it's possible and I'm really sure these don't work, just don't know the syntax well enough to make it go. I believe the underlined portions are definitely wrong... can someone help?
Jan 31 '08 #1
6 2005
Death Slaught
1,137 1GB
Yeah go here.

^_^ Hope it helps, Thanks, Death
Jan 31 '08 #2
well i read through that link and i'm not sure what to use. It seems that is instructions for how to code a page. I want a bookmarklet that I can paste into my address bar that will change which item is in the dropdown box. The linked page says that the user needs to input. I want to automate that input. Is that possible?

also would it be possible to do this by form/element/desired option number?
Jan 31 '08 #3
Death Slaught
1,137 1GB
I think you can automate it, but i'm not sure how.

I though you wanted to be able to erase an option and then replace it with something else. Sense that's not it I can't really help you much, someone will though.

^_^ Thanks, Death
Jan 31 '08 #4
acoder
16,027 Expert Mod 8TB
You're looking for the selectedIndex property. Set that to the index of the select box - starting from 0.
Feb 1 '08 #5
javascript:document.form[0].element[0].selectedindex(0)
javascript:document.form[0].element[0].selectedindex[1]

neither work... it's close to the right code but it doesn't work.
BTW i need a bookmarklet (able to paste it in the address bar, hit enter and see the change happen.

thanks for any input you may have!
Feb 1 '08 #6
acoder
16,027 Expert Mod 8TB
That would be:
Expand|Select|Wrap|Line Numbers
  1. javascript:document.forms[0].elements[0].selectedIndex=0
Note the case - JavaScript is case-sensitive.
Feb 2 '08 #7

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

Similar topics

7
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 =...
4
by: Doslil | last post by:
I have a form which has a subform.In the main form I have only one field (this is a drop down list and has a query attached to it) which selects empno,Name from the EmployeeInformation table. ...
6
by: Mike Wilson | last post by:
Dear Group, I have a heirarchical set of database tables, say - "order" and "order_type" and want to display a series of orders in a grid control, and in place of the order_type foreign key...
0
by: koti | last post by:
hi i have written some code for selecting an item in combobox dropdown list which is in datagrid columm. by scrolling the mouse we select any item from the list. but by pressing the down key...
2
by: sck10 | last post by:
Hello, I am using the following and am trying to figure out how to select the nth item of a list in a DropDownList. //Insert and Add items to the DropDownList ddlPayStatus.Items.Insert(0,...
4
by: Panna | last post by:
Hey there I am using phpMyAdmin and MySQL to develop a dbase application. I have a dropdown menu on one of the pages which gets populated automatically with data from a table in the database....
4
by: pradeep234 | last post by:
I want to display a content dynamically when the user selects a item from a dropdown menu
3
by: mark.norgate | last post by:
Hi Another problem... My drop down is always defaulting to selecting the first item in the drop down, even though I've got code specifically to change it to a different item: Dim adapter...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...

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.