Here is my options select from my form. Its dynamically generated with php.
Code:
<select id="upgrade[]" name="upgrade[0]" onchange="javascript:calTotal(this);">
<option value="1">1</option><option value="2">2</option>
</select><br />
<select id="upgrade[]" name="upgrade[1]" onchange="javascript:calTotal(this);">
<option value="1">1</option><option value="2">2</option>
</select><br />
<select id="upgrade[]" name="upgrade[2]" onchange="javascript:calTotal(this);">
<option value="1">1</option><option value="2">2</option>
</select><br />
Using javascript I want to get the selected value. Here is what I have, but its getting no where:
Code:
function calTotal(aVar)
{
var c = document.getElementsByName(aVar);
c = c.length ? c : [c];
for(var i=0; i<c.length; ++i)
{
if(c[i].value==1)//I am getting undefined here
{
}
}
Is there a way to loop through an array of option selected like the one I have here?
I'm trying to get the value of a selected option value. I've tried using getElementById("fieldname").selectedIndex.value and formname.elements["fieldname"].options[selectedIndex].value with no joy.
I'm new to JavaScript. I'm trying to create my form in such a way that if 'Premium' is selected, a the text box with label 'membership no' is displayed and if 'bronze' is select, the drop-down list 'sponsor' is displayed instead....here's what my form looks like...
I am trying to display a rel of each option as they are selected into a div below it . There are several selects of classProductAvailability on the page. When one of the selects changes, I'd like the value of the rel of the selected option to display.At first it seems to work, but only if you start by changing the last pull down menu. The trouble seems to be in the"select.ProductAvailability option:selected", this needs to be written for this instance, not all of the selects of that class on the page. How do I write that, I've tried$(this+" option:selected") but it won't take.
what i want to do is have a selection from 'tst' trigger an input into 'choose' from the data inputted into the 'fname' and 'lname' fields.
for example, i want option '1', when selected to draw the input from 'fname' and place it into 'choose'
or i might want to select the data in 'lname' instead, so i will tie option 2 to it, so when the user selects option 2 the contents of 'lname' go into 'choose' instead.
I am trying to create a form with radio buttons, when an option is selected and submitted it comes up with a message but i cant get it working. If the first radio button is selected I want the message class 1 and if the second class 2 etc
I have a form set up and I need to set the validation so if one option is selected from a picklist, they need to complete a text field as well.
This is the code i'm using:
Code:
Reason is a picklist, I want it to show the alert when option 1 from the picklist is selected and no text is in the Row_Number field.
If any of the other options are selected, I want to make sure the Row_Number field is blank.
As I said, I'm sure this is a very simple thing, but I been working on it for ages, and cannot get it to work, I get the alert every time the Row_Number field is blank.
I have some form fields that the user can either type in or he can check a checkbox so that MySQL data for an option selected from a dynamically generated (PHP/MySQL) select menu is filled in. How can this be implemented? I have the code for the select menu.
In the code below I want to alert the selected option of select. In Mozilla the code works (If I choose "3" alerts it). In IE alerts: nothing appear --------------------- <script> function hi() { d = document.getElementById("day").value; alert(d); } </script> <select id=day onchange="hi();"> <option>0 <option>1 <option>2 <option>3 <option>4 </select> ---------------------
I'm trying to update a part of my page depending on the option selected from a drop down menu. A few of the options can trigger this event. So to do this i've given those options a class name, that i can check against when they're selected. eg...
Code:
So if 'test2' or 'test4' are selected it will check if the class name is present then do the rest. But I cant get the class name from JQuery. I've tried..
I have a select box with a few options. When the page loads I need to get the selected option in this select box and alert its inner text. Yet everything I try out on the net that should work wont work in IE, all other browser its fine. show me the TRUE and correct way to get the inner text of a option from a select box in IE?
I have multiple select boxes that have various options such as 'bangles', 'rings', 'earings' etc and I have a div that doesn't display until an option has been selected from one of the select boxes. If the option 'rings' is selected I don't want to display the div '#size'.
Jquery function:
The trouble I'm having is that I can't figure out how to use $(this) with option:selected. if I simply put the id of one of the select boxes then it works, but only for that one select box. I want it to be dynamic.
Basically, I have a <select> drop down with a bunch of <option>s, each with an onmouseover command. The problem is that if I click on one of the options, it loses its mouseover effect. Here's the code:
Code: <select> <option onmouseover="tooltip('Some stuff')">Blah</option> <option onmouseover="tooltip('Some more stuff')">More blah</option> <option onmouseover="tooltip('Even more stuff')">Blah blah blah</option> </select>
The tooltip() function creates a basic tooltip. While the drop-down menu is open, the onmouseover functions work just fine. It's when the option has been selected that it stops working.
I am trying to make a form that collects "Number of Children" a parent has. If they select "4" from the select input, then I want to slidetoggle out the appropriate divs, one for each child.
[Code]...
I have been able to use slidetoggle in the past when attached to a button, but this one has me lost. Anyone know how to accomplish this?
I have an html drop down list. the list has an 'other' option. when the other option is selected I want a text box to pop up to the left of it for entry. I was thinking about using a hidden <div> to contain the text box. and when other is selected to unhide it. How do I unhide it when other is selected?
I wish to identify the option chosen in the function but not by its value, by its position:
<script> function goHere(){ var s = document.getElementById("input");
[code]....
I was hoping that variable "u" would be either 0, 1, 2, or 3.How can I get a variable to alert me the position of the selected option in the form? I think it is elements[i].
I have a dropdown box with 2 options: Free or UpgradedI need to do 2 separate things depending on which one is chosen.If Free, then set the value in fourth text field to 9999else, set value in Fourth field to 5555.
<head> <script type="text/javascript"> function calculate()