GetElementsByName()
Mar 13, 2006
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
View 1 Replies
Jan 11, 2007
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;
}
getSelectValue ('belongsto')
...
<select name="belongsto" ...
yet I always get the error "sel has no properties". Any idea what's
wrong? Is there a simpler way?
View 4 Replies
View Related
Apr 20, 2006
I'm trying to get all the "divs" that have a given NAME using
getElementsByName(). For example, the following code:
<html>
<head>
<script type="text/javascript">
function on_load()
{
var pages = document.getElementsByName("name");
alert(pages.length);
}
</script>
<body onload="on_load()">
<p name="name" id="id">Teste</p>
</body>
<html>
when I open this page in Firefox, it gives me a popup saying "1", that
is correct. But if I do it in Opera, it gives me "0"....
View 2 Replies
View Related
May 29, 2011
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..
<li class="value">
<input type="text" autocomplete="off" name="customerName" value="<?=$fullname;?>" style="width: 200px;" onChange="checkValidFormInput(this.name, '');">
<div style="float: left;" id="customerNameImg"></div><br style="clear:both">
</li>
View 4 Replies
View Related
Jun 6, 2011
I got a problem with getElementsByName in IE 7 check that if i do this
So if i've changed its type to radio so it's give me the right number so what the hell
why ?
View 1 Replies
View Related
Aug 17, 2007
How can I fetch a part of the array in IE?
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");
if (newPlan === true) totalPlans = totalPlan + 1;
else totalPlans = totalPlan;
var matchValue = 0;
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;
newTbody = createMatchPowerline(newTbody, key, nr, matchValue);
}
div.appendChild(newTbody);
}
totalMatch.value = total;
}
Does anyone have an idea on how I can fetch those values in IE?
View 9 Replies
View Related
Sep 24, 2011
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?
View 4 Replies
View Related
May 8, 2006
I got the following error in a javascript I wrote. The script works
fine, but why is the error being displayed???
function chgMusicLink(userid,userlink,usertype) {
var card_music_id = document.getElementsByName(userid)[0].value;
document.getElementsByName(userlink)[0].href="/card_music_preview.tcl?card_music_id="+card_music_id+"&card_music_type="+usertype;
}
View 4 Replies
View Related
Sep 4, 2007
I am passing a value through query string to a popup and then trying to pass it back to the main page... I store the value in a hidden input box
<input type="text" name="FromZip" id="FromZip" value="<% response.write(Request.QueryString("txtZipFr")) %>" />
and am passing it back through query string to the main page with
[Code]...
View 2 Replies
View Related