erick30
06-30-2004, 06:29 AM
Hi!
In my website I have several select objects that retrieves its data from the database, and its values are many times different to (0, 1, 2, 3, 4,..), I mean the normal index value that javascript assigns to these items. So, the problem is for example: if the select second value is 5, when I write a javascript function with a variable referring to the selected value, the value that is sent to the server if the user select the second item is 2, and the real value retrieved from the database is 5, so, I want to send '5' value not '2'.
Example 1:
function checkValue() {
var userType = form1.userT.options[userT.SelectedIndex].value
if (userType == "5") { I mean, the second item value selected
alert("some text ")
form1.userType.focus()
return false; }
...
Example 2:
function addArticle()
{
for(var i=0; i<document.getElementById('selectedCert').length; i++)
{
if(document.getElementById('selectedCert').options[i].value == document.getElementById('QualityCert').options[document.getElementById('QualityCert').selectedIndex].value)
{
alert("Already exists");
return false;
}
}
document.getElementById('selectedCert').options[document.getElementById('selectedCert').options.length]=new Option (document.getElementById('QualityCert').options[document.getElementById('QualityCert').selectedIndex].text, document.getElementById('QualityCert').options[document.getElementById('QualityCert').selectedIndex].value);
}
How can I solve this problem?
Thank you,
Erick
In my website I have several select objects that retrieves its data from the database, and its values are many times different to (0, 1, 2, 3, 4,..), I mean the normal index value that javascript assigns to these items. So, the problem is for example: if the select second value is 5, when I write a javascript function with a variable referring to the selected value, the value that is sent to the server if the user select the second item is 2, and the real value retrieved from the database is 5, so, I want to send '5' value not '2'.
Example 1:
function checkValue() {
var userType = form1.userT.options[userT.SelectedIndex].value
if (userType == "5") { I mean, the second item value selected
alert("some text ")
form1.userType.focus()
return false; }
...
Example 2:
function addArticle()
{
for(var i=0; i<document.getElementById('selectedCert').length; i++)
{
if(document.getElementById('selectedCert').options[i].value == document.getElementById('QualityCert').options[document.getElementById('QualityCert').selectedIndex].value)
{
alert("Already exists");
return false;
}
}
document.getElementById('selectedCert').options[document.getElementById('selectedCert').options.length]=new Option (document.getElementById('QualityCert').options[document.getElementById('QualityCert').selectedIndex].text, document.getElementById('QualityCert').options[document.getElementById('QualityCert').selectedIndex].value);
}
How can I solve this problem?
Thank you,
Erick