473,406 Members | 2,705 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,406 software developers and data experts.

Add event to Drop down list with no ID

Hello,

My page is dynamically generating a product listing for a drop down list based on our options. For example, one page might show this:

[HTML] <select name=stylekey>
<option value="7784">Naos 70 Regular Cobalt</option>
<option value="7783">Naos 70 Regular Graphite</option>
[/HTML]
The name is always "stylekey". Basically I don't have access to this code, so I can't really modify the select list by adding events. What I want is for a user to go to a given page when they select an item from the drop down list without having to push a button.

I added in this javascript:
[HTML] <script language="JavaScript" type="text/JavaScript">
<!--
function MM_jumpToProduct(value) {
window.location="address to site" + value;
}
//-->
</script>
[/HTML]
Where address to site was the physical path. This code works perfectly if I add this to the <select button (just on a test page):
Expand|Select|Wrap|Line Numbers
  1. onChange="MM_jumpToProduct(test.value)"
The problem is I can't add this event to the select part because I don't have access to it. I tried setting this event on a div as well as on a span that encompasses the <select>. This didn't work. If I could add the id property to the select I think that would work to -- but I can't. I'm wondering is there a way to add this property to the control somewhere other than the control itself?

Sorry for the beginner question, and thanks for any help!
Oct 12 '07 #1
5 2430
drhowarddrfine
7,435 Expert 4TB
select and option are part of a form and a form needs a button to submit it. At least in html. What you want is probably do-able using javscript and the DOM on the client side but this needs to be asked on that board. I can send this there if you wish.
Oct 12 '07 #2
numberwhun
3,509 Expert Mod 2GB
Hello,

My page is dynamically generating a product listing for a drop down list based on our options. For example, one page might show this:

<select name=stylekey>
<option value="7784">Naos 70 Regular Cobalt</option>
<option value="7783">Naos 70 Regular Graphite</option>

The name is always "stylekey". Basically I don't have access to this code, so I can't really modify the select list by adding events. What I want is for a user to go to a given page when they select an item from the drop down list without having to push a button.

I added in this javascript:
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_jumpToProduct(value) {
window.location="address to site" + value;
}
//-->
</script>

Where address to site was the physical path. This code works perfectly if I add this to the <select button (just on a test page):
onChange="MM_jumpToProduct(test.value)"

The problem is I can't add this event to the select part because I don't have access to it. I tried setting this event on a div as well as on a span that encompasses the <select>. This didn't work. If I could add the id property to the select I think that would work to -- but I can't. I'm wondering is there a way to add this property to the control somewhere other than the control itself?

Sorry for the beginner question, and thanks for any help!
If you don't have access to change the source, then I would find someone who does, explain what you want to do and see if they can make the change for you.

Regards,

Jeff
Oct 12 '07 #3
Yes sorry - I guess this would fit better on the JS board.

As for the second response, that's my last resort... it's be much less costly if I could find a work-around.
Oct 12 '07 #4
Bah of course now I figure it out -- just had to use getElementsByName instead of by ID.
Oct 12 '07 #5
acoder
16,027 Expert Mod 8TB
Changed the thread title to be more descriptive.

That was one way of accessing the object. You could also have used the form.elements array.
Oct 15 '07 #6

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

Similar topics

0
by: Stephen Witter | last post by:
I have two asp pages. Both have similar purposes. I am trying to get the inline frame in both pages to update (submit) when a user clicks on a drop-down box (I would prefer the change or after...
2
by: kmnotes04 | last post by:
Is it possible to link one drop-down box to another? For example, if a name is chosen from a drop-down list, can another drop-down list then automatically display the person's office as a result of...
3
by: Miguel Dias Moura | last post by:
Hello, i have an ASP.NET / VB page where i have a few 4 groups of Drop Down Lists. Each group of Drop Down Lists include 3 Drop Down Lists for date such as: DAY, MONTH, and YEAR. I don't want...
5
by: Vigneshwar Pilli via DotNetMonster.com | last post by:
string connectionString1 = "server=(local); user=sa;password=sa; database=sonic"; System.Data.SqlClient.SqlConnection dbConnection1 = new System.Data.SqlClient.SqlConnection(connectionString1);...
2
by: Dave A | last post by:
I am stuggling with databinding a drop down list, hooking into the SelectedIndexChanged and attempting to avoid using the viewstate. The drop down list is quite large so I would prefer to avoid...
3
by: Mike Collins | last post by:
I'm not feeling too smart right now, but I cannot get the correct drop down list value from a drop down I have on my web form. I get the initial value that was loaded in the list. Can someone show...
5
by: mc | last post by:
I've got three controls on a page a Drop Down List, a List Box and a Button I've added 3 items to the Drop Down List I have added some code in the Button onClick Event Handler, as below...
7
by: slekshmipriya | last post by:
Hai friends.I have a pblm with my drop down list onchange event.The pblm is as follow I have a drop drown list with items 1,2 ,3 etc. On selecting an item from the drop down list i want to...
1
by: jacbyrd | last post by:
I have created a user control that is a drop down list that pulls from my database. I then drop that control into a detailsview control on an insert item template. When I run the insert command,...
2
by: McGeeky | last post by:
Hi. I have a read only GridView. For each row I want to display a drop down list which contains a list of actions the user can select from for that particular row. E.g. "view details". When they...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.