
June 2nd, 2004, 02:23 PM
|
|
Registered User
|
|
Join Date: May 2004
Posts: 3
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
Use a Javascript Function with multiple variables
I'm in the process of developing a remote order entry system for our medical laboratory and need help with one javascript function.
Screenshot is here of the page I'm working with:
http://www.rml-lab.com/ss.gif
I have a listing of the Physician's top ordered tests, and their Organization's top ordered tests, but now need a "Grouping of tests" so a single click can order multiple tests. So when maybe a new patient comes in they can click on a "grouped test" called "new patient admit" and would order the following tests for example cbc, bmp, mdg, etc..
Here is my code so far:
Code:
function setCode(theBox){
elem = document.entry.elements;
for(i=0;i<elem.length;i++){
if(elem[i].name.match(/test\d+/)){
if(theBox.value==elem[i].value){
if(theBox.checked==false){
elem[i].value = "";
closeGap(elem[i]);
document.entry.search.value="";
document.entry.search.focus();
}
return false;
}
if(elem[i].value==""){
elem[i].value=theBox.value;
document.entry.search.value="";
document.entry.search.focus();
return false;
}
}
}
return false;
}
function removeCode(theBox){
elem = document.entry.elements;
for(i=0;i<elem.length;i++){
if(elem[i].name.match(/test\d+/)){
if(theBox.value==elem[i].value){
elem[i].value = "";
closeGap(elem[i]);
document.entry.search.value="";
document.entry.search.focus();
return false;
}
if(elem[i].value==""){
elem[i].value=theBox.value;
return false;
}
}
}
return false;
}
function closeGap(theField){
theForm = theField.form;
fPref = theField.name.replace(/\d/g,"");
fNum = theField.name.replace(/\D/g,"")*1;
for(var i=fNum;theForm[fPref+(i+1)];i++){
theForm[fPref+i].value = theForm[fPref+(i+1)].value;
}
}
Each row of data looks like so:
Code:
<td bgcolor="ffffff" align="center"><img src="../images/select.gif" border="0" value="DRAWING FEE" onClick="setCode(this)"></td>
<td bgcolor="ffffff"><a href="info.cfm?id=489" class="link1" target="_blank">DRAWING FEE</a></td>
<td bgcolor="ffffff" align="center"><img src="../images/select.gif" border="0" value="TSH (THYROID STIM. HORMONE)" onClick="setCode(this)"></td>
<td bgcolor="ffffff"><a href="info.cfm?id=349" class="link1" target="_blank">TSH (THYROID STIM. HORMONE)</a></td>
<td bgcolor="ffffff" align="center"><img src="../images/select.gif" border="0" value="LIPID PANEL" onClick="setCode(this)"></td>
<td bgcolor="ffffff"><a href="info.cfm?id=202" class="link1" target="_blank">LIPID PANEL</a></td>
How can make it so if there are multiple tests defined to each row that when the user clicks on the checkmark I can run the say 10 tests though the above function and fill in the test boxes shown in the screenshot?
Sample row of data for a "grouped test" would look like:
Code:
<td bgcolor="ffffff" align="center"><img src="../images/select.gif" border="0" value="CBC|BMP|MDG|Urine Culture" onClick="setCode(this)"></td>
<td bgcolor="ffffff"><a href="profile.cfm?id=CBC|BMP|MDG|Urine Profile" class="link1" target="_blank">Sample Admit Profile</a></td>
I would also have to use the | character to break up the tests, I do have test names that have commas in the test name.
Any help would be GREATLY appreciated!
|