Question : Custom Attribute Javascript Loop trough elements.

So i have this code:

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Test</title>
</head>
<body>
<form name="formtab1" id="formtab1">
  <select name="ZoneDropdown" id="ZoneDropdown" onchange="DisplayFormValues()" class="dropdown">
    <option value="" title="">Please Select</option>
    <option value="BLP" title="POLOB" price="5.0000">BLP</option>
  </select>
  <select name="LogoDropdown" id="LogoDropdown" onchange="DisplayFormValues()" class="dropdown">
    <option value="vv" title="tester" price="2.0000">Please Select</option>
    <option value="BLP" title="POLO" price="5.0000">BACK</option>
  </select>
  <input id="AddEmb" name="AddEmb" type="text" />
</form>
<script type="text/javascript">
function DisplayFormValues() { var str = '';
var elem = document.getElementById('formtab1').elements;
for(var i = 0; i < elem.length; i++) { str += elem[i].value };       <----------- I need elem[i].price not value |
		document.getElementById('AddEmb').value = str;
}

function on()
   {
   var w = document.formtab1.ZoneDropdown.selectedIndex;
   var selected_text = document.formtab1.ZoneDropdown[document.formtab1.ZoneDropdown.selectedIndex].getAttribute('price');
   alert(selected_text);
   }
</script>
</body>
</html>


I have multiple dropdowns, mu goal is to sum up the Custom Attribute "Price". But i cannot get the attribute to pull up the value. While example function "on" works. When i do it inside a loop it fails.

I tried:
1:
 elem[i].price, elem[i].getAttribute('price') 
and a bunch of things but nothing worked for me.

Thanks

Answer : Custom Attribute Javascript Loop trough elements.

Hey, sorry I have been quit busy.  I ended up realizing we could do this all in one line and pop up a message box for you about the bad directory.

The attached code will check if the directory does not exist, and if it doesn't exist it will pop-up a message box warning you that the directory does not exist.

The code will continue to function and move on to the next file even if you don't click the message box. so you don't have to worry about this causing the script to stop functioning.
1:
2:
ECHO OFF
FOR /F "Tokens=1,* Delims=_" %%F IN ('DIR /A:-D "J:\ScanFiles\Fax dump\*_*.pdf" /B ') DO IF NOT EXIST "J:\ScanFiles\%%F\" ( MSG %Username% "The MovePDF Script Encountered an Error Moving a File to a Directory:                    The Directory Does Not Exist:  J:\ScanFiles\%%F\ " ) ELSE (MOVE /Y "J:\ScanFiles\Fax dump\%%F_%%G" "J:\ScanFiles\%%F\%%F_%%G")
Random Solutions  
 
programming4us programming4us