I've tried to access the value of a selected option through the
following getSelectValue function, passing the name of the select
function getSelectValue (name) {
var sel = document.getElementsByName(name)[0];
var i = sel.options.selectedIndex;
return i == -1? "": sel.options[i].value;
}
I want to use document.getElementsByName('name').value to retrieve a value of the field 'name', but it returns undefined. But function document.xxxform.name.value returns the correct value.
I thought this 2 functions are identical? If getElementsByName is not the same as the later function, is there any other function I can use which is same as document.xxxform.name.value, but allow me pass in a variable name of the 'name'? I want to do something like:
var name = 'label'+i text = document.getElementsByName(name).value
I am trying to add a green tick or red cross to my form so that the user will know if they have filled out the form correctly before submitting it and getting told that they need to fill out this or correct that.I have added NAME to each form field and have been using this to read the content but for some reason I am unable to read what is in the field I get the error, 'undefined'.this is what code I have started on...
function checkValidFormInput(id, noCheck) { if (noCheck == '') { var idValue = document.getElementsByName(id);[code].....
my code is still in the early stages and is missing the other parts to place a red cross, as the moment i am working on placing the green tick.what I have wrong in my code that is causing it not to read the form field.my form field is coded as so..
The code works as expected in Opera and Firefox, but IE returns an error saying that matchPaid does not contain a value.
As it seems IE does not pull any of the input fields belonging in the array.
I believe the issue lies in this line:
var matchPaid = document.getElementsByName("plan_bonus_amount["+key+"][]");
The rest of the function:
JavaScript Code:
function updateMatchPowerline(total, newPlan) { var totalPlan = parseInt(document.getElementById("total_plans").value); var totalMatch = document.getElementById("total_match");
for (var key=0;key < totalPlans;key++) { var div = document.getElementById("match_table_"+key); var newTbody = document.createElement("tbody");
var match = new Array();
if (key < totalPlan && parseInt(totalMatch.value) > 0) { /*Fetch the current values, then clear the table*/ var matchPaid = document.getElementsByName("plan_bonus_amount["+key+"][]");
for (var nr=0;nr < parseInt(totalMatch.value);nr++) { match[nr] = parseFloat(matchPaid[nr].value); }
remove(div); }
for (var nr=0;nr < total;nr++) { if (typeof(match[nr]) != 'undefined') matchValue = match[nr]; else matchValue = 0;
I am trying to adapt an existing script which returns a list of URLS from my website based on an entry in a search box. I would like to adapt it so that I can enter a value other than the string value "xxx" but so that I can search for "xxx" or "yyy". I can see that the script uses the function GetElementsByName with a Name value. Is there any way that I can change the value of the Name to be '"xxx" or "yyy"' instead of just "xxx" or should I be using a different function?
I want to add more dropdown options which are dependent on previous options. Now I have "hand" and "loft". I want to add next option "model" How to add third dropdown option box?
i currently have a few problems with my code, but currently i want to get my options into my function
<select id="menu"> <option value="first">First Time User</option> <option value="Frequent">Frequent Flier</option> <option value="Buying">Buying a Degree</option> </select>
How do I use this info to make it part of my function, for example when First Time user is selected and the function is executed it i want a windows.alert to come up but i don't know how to code that.
I have a bit of a question about CGI...I'm not very knowledgeable about it, so I have a specific question. Can you set up a site in which sites can be rated using CGI?
That dosn't work. I'm just using the title attribute as a place to hold the information I need. Maybe there is another attribute that would work better for this? How can I get the contents of the attribute?
<script> alert("You are not allowed to see this page"); self.location="javascript:history.go(-1)"; </script> The above script has one option. I like to make two options(yes or no) like the following.
Code: <script> alert("Are you sure to delete?"); Yes(self.location="delete.php"); No(self.location="javascript:history.go(-1))"; </script>
I have one select, I can say wich element is selected:
<select name="myselect"> <option value="100">A</option> <option value="101">B</option> <option value="102">C</option> </select> this line will select the option B
myselect.options.selectedIndex = 1; but, how can I do if I want to select the option B without knowing itĀ“s position? I mean, I want to select the option B and the value 101, but I donĀ“t know itĀ“s position
I have a drop down with alot of options say about 6000 cities and districts. I need to select all options if user selects "All checkbox". I use "on change" and a for loop to do this, but it takes a lot of time to select all these options. Is there any faster way to select all these options?
function selectAll() { var element = document.getElementById("location"); var length = document.getElementById("location").length;
I have two drop down box's in a form, how would I go about changing the options of the seccond one depending on what option is selected in the first one?
For example, if there's a drop down box with "a", "b" and "c" as the options, and another drop down box with "1", "2" and "3" as the options; then when you select "a" on the first drop down box the values of the seccond one changes to "a1", "a2" and "a3". This should work for all the options of the first drop down box.
In JS, how can I change the selected value of a dropdownlist(select options) I know the value of indexed value of the selected value before it is changed.
I got this simmple function, It stays on onChange on select and on change it hides all objects with ID equal to select name plus the optionvalue. It works perfectly in Opera and FF, but IE crashes because says that options object is null
the problem is in for (optionId in what.options) It seems that IE does NOT return the list of options, but only some other objects: language scrollheight, istextedit, currentstyle, document, and onmouseup
Please can you help me how can I go throuth that cycle? I need to get the values of all options in select. Thank you
function showHide (what) { selectedId=what.options.selectedIndex; selectedValue=what.options[selectedId].value; selectedObject = document.getElementById(what.name+selectedValue); selectedObject.className=""; for (optionId in what.options) { optionValue=what.options[optionId].value; if (optionValue) { optionObject = document.getElementById(what.name+optionValue); if (optionId!=selectedId) { optionObject.className="hidden"; } } } }
The user must bem select options in this 4 files in order, for example, he must bem select first "First Choice" next "Second Choice"... The options not be same.
I notice when I view the source of a lot of Google pages (for example, my GMail Inbox page source) that the src option in <scripttags will refer to addresses like "?foo=bar&bla=bla". How does this work exactly? Does the server side script return a string containing javascript code? How does it know which server side script to call? Does it look for an index file of some type?
Something else I just noticed in the address of this page (I know this is off topic, sorry)... this page sends GET data to a "place" named 'post', but 'post' has no file extension. How does this work?
I'm working on a small scrolling popup window that mimicks an instant message window. I've currently got it all set up and working however I would like a way to have multiple var html_code options that can be picked at random. For example, each option would have a different image and text in the box.