bmsande
asked on
How set values of dynamic (cascading) select boxes
I have a form that contains a "location information" section that enables the user to select a high level location, then each subsequent select box is dynamically displayed based on the previous choice (see screenshots).
This works great for a first entry, however i'm trying to implement a lookup feature, that would automatically populate the select boxes. I've been successful with the first two levels, but I'm stuck trying to get the third level to work.
Note: I believe this has something to do with the asynchronous processing since there is a slight delay after each selection since the system has to do a database lookup to get the select options, then it has to display to the page.
Here is the entire form-- note that its contained within an application that supports custom tags, so hopefully its not too confusing.
The section in question is "//set location options"
11-19-2013-5-04-23-PM.png
This works great for a first entry, however i'm trying to implement a lookup feature, that would automatically populate the select boxes. I've been successful with the first two levels, but I'm stuck trying to get the third level to work.
Note: I believe this has something to do with the asynchronous processing since there is a slight delay after each selection since the system has to do a database lookup to get the select options, then it has to display to the page.
Here is the entire form-- note that its contained within an application that supports custom tags, so hopefully its not too confusing.
The section in question is "//set location options"
<!DOCTYPE XHTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
PowerView: initiate_workflow-PV
-->
<html lang="en">
<head>
<title >Well Connect CCS Request</title>
<link href="[LL_REPTAG_SUPPORTDIR /]common/css/rime.css" rel="stylesheet" type="text/css">
<link href="[LL_REPTAG_SUPPORTDIR /]wellconnect/css/wcstylesheet.css" rel="stylesheet" type="text/css">
<link href="[LL_REPTAG_SUPPORTDIR /]wellconnect/css/wclinks.css" rel="stylesheet" type="text/css">
<script src="[LL_REPTAG_SUPPORTDIR /]common/js/prototype.js" type="text/javascript"></script>
<script src="[LL_REPTAG_SUPPORTDIR /]wellconnect/js/utilities.js" type="text/javascript"></script>
<SCRIPT SRC="[LL_REPTAG_LIBPATH /]ajax.js"></SCRIPT>
<script>baseURL = "[LL_REPTAG_URLPREFIX /]";</script>
<SCRIPT LANGUAGE="JavaScript">
// These are standard form functions.
function markDirty()
{
}
function addRowSubmit( fieldName, index )
{
document.myForm.func.value = 'webform.AttrValueAdd';
document.myForm.LL_AttrFieldName.value = fieldName;
document.myForm.LL_AttrFieldIndex.value = index;
document.myForm.submit();
}
function delRowSubmit( fieldName, msg )
{
if ( confirm( msg ) )
{
document.myForm.func.value = 'webform.AttrValueDelete';
document.myForm.LL_AttrFieldName.value = fieldName;
document.myForm.submit();
}
}
/*** Custom functions ***/
// Initialize some things-may or may not be needed.
function onInitPage() {
var leaseTypeFld=document.getElementById("_1_1_186_1");
// Make sure fields are shown/hidden depending on radio buttons.
getradiovalues( );
// Set Location information (Land Desription)
loadAllLocations(1, false);
// Set the Lease Type correctly.
leasetypeSelected(leaseTypeFld);
// Set Operator if one already selected in the drop-down.
setOperatorName();
}
// Get the name for a selected Operator.
function setOperatorName()
{
var selectOperator = document.getElementById("_1_1_69_1_72_1");
var operatorNameFld = document.getElementById("_1_1_69_1_70_1");
normalborder(selectOperator);
// Get name from text items shown. Strip off any operator code.
if (selectOperator.selectedIndex == 0) {
// Nothing selected, set to blank.
operatorNameFld.value = "";
} else {
operatorNameFld.value = selectOperator.options[selectOperator.selectedIndex].text;
var j = operatorNameFld.value.lastIndexOf(" - ");
if (j >= 0) {
operatorNameFld.value = operatorNameFld.value.substring(0,j);
}
}
}
// Get and set the Option Value based on Name
function setSelectOption(selObj, name)
{
var x=document.getElementById(selObj);
for (var y=0;y<x.length;y++){
if(x.options[y].text==name){
x.value=x.options[y].value;
}
}
}
//Lookup well connect info based on well name, autopopulate fields if well is found
function getWCdata() {
var optHandlerFunc = function () { JSfunction() };
var handlerFunc = function () { executeJS( http_request, optHandlerFunc ) };
var param = "&wellname=" + document.getElementById("_1_1_5_1").value;
// $TargetWR is a constant and objectID of the target WR.
sendRequest([LL_REPTAG_$GetWCdata-swr /], handlerFunc, param );
// Handle the response to sendRequest
function executeJS(http_request, JSfunction) {
if (http_request.readyState == 4) {
if (http_request.status == 200) {
// recieve the results of the webreport via a pipe delimited string
var results= http_request.responseText;
setWCdata(results);
if ( JSfunction ) {
// execute any user passed function
JSfunction();
}
} else {
alert('There was a problem with the request.');
}
}
}
function JSfunction() {
// Add anything else here after the results are displayed
}
}
// Auto populate the fields if an existing well connect is found
function setWCdata(wcdata){
var str=wcdata
if(str.length==11){
alert("No Well Connects found under that name, you will need to fill out the form manaully");
//reset form
document.getElementById("_1_1_69_1_72_1").value="";
document.getElementById("isOpShipper1").checked=false;
document.getElementById("isOpShipper2").checked=false;
document.getElementById("_1_1_61_1").value="";
document.getElementById("_1_1_8_1").value="";
document.getElementById("_1_1_187_1").value="";
document.getElementById("_1_1_188_1").value="";
document.getElementById("_1_1_189_1").value="";
document.getElementById("_1_1_186_1").value="";
document.getElementById("_1_1_185_1").value="";
document.getElementById("_1_1_12_1").value="";
document.getElementById("isWellStaked1").checked=false;
document.getElementById("isWellStaked2").checked=false;
getradiovalues();
}
else{
//divide string by "|"
var wcarray = wcdata.split('|');
//split each record into [sort , value] array
var wcarray2d = new Array();
for (var i = 0; i < wcarray.length; i++){
wcarray2d[i] = wcarray[i].split('~');
}
for (var i = 0; i < wcarray2d.length; i++){
//set operator
if(wcarray2d[i][0]==100){
document.getElementById("_1_1_69_1_72_1").value=wcarray2d[i][3];
}
//set operator is shipper
if(wcarray2d[i][0]==200){
//if yes set value
if(wcarray2d[i][1]=="Yes"){
document.getElementById("isOpShipper1").checked=true;
getradiovalues();
document.getElementById("_1_1_61_1").value="";
}
else{
//if no set radio and show shipper name text input
document.getElementById("isOpShipper2").checked=true;
getradiovalues();
}
}
//estimated production
if(wcarray2d[i][0]==1000){
//remove any commas
var str=document.getElementById("_1_1_8_1").value=wcarray2d[i][1];
str= str.replace(/,/gi,'');
document.getElementById("_1_1_8_1").value=str;
}
//set location options
if(wcarray2d[i][0]==1302){
document.getElementById("typeselect_1_1_190_" + 2).value=wcarray2d[i][2];
typeSelectionChanged(document.getElementById("typeselect_1_1_190_"+ 2));
setSelectOption("entityselect_1_1_190_"+2, wcarray2d[i][1]);
entitySelectionChanged(document.getElementById("entityselect_1_1_190_"+2));
}
if(wcarray2d[i][0]==1303 ){
var temparray= new Array();
temparray=wcarray2d;
var temp=temparray[i][1];
var digit=temparray[i][0];
var ldigit=String(digit.charAt(temparray[i][0].length-1));
setTimeout(function(){
setSelectOption("entityselect_1_1_190_"+ ldigit, temp);
entitySelectionChanged(document.getElementById("entityselect_1_1_190_"+ ldigit));
},1000);
}
if(wcarray2d[i][0]==1304 ){
temparray1= new Array();
temparray1=wcarray2d;
var temp1=temparray[i][1];
var digit1=temparray[i][0];
var ldigit1=String(digit1.charAt(temparray1[i][0].length-1));
setTimeout(function(){
setSelectOption("entityselect_1_1_190_"+ ldigit1, temp1);
entitySelectionChanged(document.getElementById("entityselect_1_1_190_"+ ldigit));
},2000);
}
//set additional location
if(wcarray2d[i][0]==1400){
document.getElementById("_1_1_12_1").value=wcarray2d[i][1];
}
//set latitude
if(wcarray2d[i][0]==1450){
document.getElementById("_1_1_187_1").value=wcarray2d[i][1];
}
//set longitude
if(wcarray2d[i][0]==1460){
document.getElementById("_1_1_188_1").value=wcarray2d[i][1];
}
//set NAD
if(wcarray2d[i][0]==1470){
document.getElementById("_1_1_189_1").value=wcarray2d[i][1];
}
//set shipper Name
if(wcarray2d[i][0]==300){
document.getElementById("_1_1_61_1").value=wcarray2d[i][1];
}
//set lease type
if(wcarray2d[i][0]==1610){
var x=document.getElementById("_1_1_186_1");
for (var y=0;y<x.length;y++){
if(x.options[y].text==wcarray2d[i][1]){
document.getElementById("_1_1_186_1").value=x.options[y].value;
leasetypeSelected(x);
}
}
}
//set lease number
if(wcarray2d[i][0]==1620){
document.getElementById("_1_1_185_1").value=wcarray2d[i][1];
}
//set well staked questions
if(wcarray2d[i][0]==1700){
//if yes set value
if(wcarray2d[i][1]=="Yes"){
document.getElementById("isWellStaked1").checked=true;
}
else{
//if no set radio
document.getElementById("isWellStaked2").checked=true;
}
}
}
}
}
// Hide/show fields based on radio buttons selected.
function getradiovalues()
{
var isOpShipperRow = document.getElementById("shipperNameRow");
var shipperName = document.getElementById("_1_1_61_1");
var multiWellCommentsRow = document.getElementById("mWellCommentsRow");
var mWellText = document.getElementById("_1_1_29_1");
// Is Operator Shipper?
if (document.getElementById("isOpShipper2").checked)
{
showField(isOpShipperRow);
}
else
{
// Default to hide shipper field.
hideField(isOpShipperRow);
shipperName.value = "";
normalborder(shipperName);
}
}
/* --------------------------- Land Description - MVC Model ------------------------- */
/*** Land Desription: Data Section - Data structures and functions of the data model. ***/
var typeValues = new Array(51); // 2-D array of types.
var typeLabels = new Array(51); // 2-D array of user-friendly labels for the types.
var typeStart = new Array(51); // 2-D array of starting index for each type in ld* arrays.
var entityValues = new Array(51); // 2-D array of values.
var entityIDs = new Array(51); // 2-D array of IDs.
var entityNumChildren = new Array(51); // 2-D array of number of children of each entity.
// Reset all data from level "start" onward.
function resetData(start) {
for (var level=start; level<=50; level++) {
typeValues[level] = null;
typeLabels[level] = null;
typeStart[level] = null;
entityValues[level] = null;
entityIDs[level] = null;
entityNumChildren[level] = null;
// Set current values to defaults.
setCurrentType(level, '');
setCurrentEntity(level, '', '');
}
}
// Load the data model starting at level "level". "start" is the starting level. This
// function calls itself recursively because it relies on asynchronous Ajax calls, and we need
// the levels to be processed in order. Note that "start" will be carried through to all recursions
// so that we always know where we started.
function loadDataFrom(start, level) {
var parentID='';
// Determine if we should do this level, or we are done, and should now populate the drop-downs.
if (level <= 1) {
parentID = '-1';
} else {
lastlevel = parseInt(level) - 1;
parentID = getCurrentEntityID(lastlevel);
var numChildren = getNumberChildren(lastlevel, parentID);
// If no parent or no children at last level current ID value, don't create this level.
// We are done recursing, and need to now load the view starting at "start" level.
if (parentID == '' || numChildren <= 0) {
populateDropdowns(start);
return;
}
}
// See if we need to do an add row submit to get a new row.
var levelFld = document.getElementById('level_1_1_190_' + String(level));
if (!levelFld) {
// Row does not exist yet, so need to do an Add Row.
addRowSubmit( '_1_1_190', level );
} else {
// We have the row, so now we need to get the data from Ajax.
var url;
url = '[LL_REPTAG_URLPREFIX /][LL_REPTAG_$GetLocationData-WR LLURL:REPORT /]&parentid=' + escape(parentID);
start_wait();
new Ajax.Request(url, {
method: 'get',
onSuccess: function(transport) {
// Get XML data.
var xmlDoc=transport.responseXML;
var ids=xmlDoc.getElementsByTagName('id');
var entity_types=xmlDoc.getElementsByTagName('entity_type');
var entity_labels=xmlDoc.getElementsByTagName('entity_label');
var entity_values=xmlDoc.getElementsByTagName('entity_name');
var num_children=xmlDoc.getElementsByTagName('num_children');
var lastType = '';
var entityType;
// If there is a problem with the location database, and we get no entries at the top level, we abort
// and leave the Submit button disabled.
if (ids.length == 0 && level==1) {
alert("Could not access location database!");
end_wait();
var saveButton = document.getElementById('SaveButton');
saveButton.disabled = true;
return;
} else {
// Init arrays.
typeValues[level] = new Array();
typeLabels[level] = new Array();
typeStart[level] = new Array();
entityValues[level] = new Array(ids.length);
entityIDs[level] = new Array(ids.length);
entityNumChildren[level] = new Array(ids.length);
// Load arrays.
for (var i=0; i<ids.length; i++){
// Load the entity data in preallocated arrays.
entityIDs[level][i] = ids[i].childNodes[0].nodeValue;
entityValues[level][i] = entity_values[i].childNodes[0].nodeValue;
entityNumChildren[level][i] = num_children[i].childNodes[0].nodeValue;
// If this is new type, load type. Array was not preallocated, so push values on.
entityType = entity_types[i].childNodes[0].nodeValue;
if (entityType != lastType) {
var entityLabel=entity_labels[i].childNodes[0].nodeValue;
typeValues[level].push(entityType);
typeLabels[level].push(entityLabel);
typeStart[level].push(i);
lastType = entityType;
// If no default selected, see if STATE is there. If so, make it current.
if (entityType.toUpperCase() == 'STATE' && getCurrentType(level) == '') {
setCurrentType(level, entityType);
}
}
/* alert('level ' + level + ': entityType='+entityType);
if (entityType.toUpperCase() == 'COUNTRY' && getCurrentEntityID(level) == '' && entityIDs[level][i] == '0') {
alert('getCurrentEntityID(level)='+getCurrentEntityID(level));
alert('entityIDs[level][i]='+entityIDs[level][i]);
} */
// If Country level and no default set, make U.S. (ID = 0) the default.
if (entityType.toUpperCase() == 'COUNTRY' && getCurrentEntityID(level) == '' && entityIDs[level][i] == '0') {
setCurrentEntity(level, entityIDs[level][i], entityValues[level][i]);
}
}
// Call ourselves recursively.
loadDataFrom(start, parseInt(level)+1);
end_wait();
}
},
onError: function(transport) {
alert("Failed to fetch information.");
//end_wait();
}
});
}
}
// Get current type at level.
function getCurrentType(level) {
var typeCurrentFld = document.getElementById('_1_1_190_' + String(level) + '_191_1');
if (typeCurrentFld)
return typeCurrentFld.value;
else
return '';
}
// Get current type index at level.
function getCurrentTypeIdx(level) {
var typeCurrentFld = document.getElementById('_1_1_190_' + String(level) + '_191_1');
if (typeCurrentFld && typeValues[level] != null && typeValues[level].length > 0) {
for (var i=0; i<typeValues[level].length; i++) {
if (typeValues[level][i] == typeCurrentFld.value)
return i;
}
}
// default is first one.
return 0;
}
// Get current starting index in entity array based on current type selected.
function getCurrentTypeStart(level) {
var idx = getCurrentTypeIdx(level);
if (idx < typeStart[level].length) {
return typeStart[level][idx];
}
}
// Get current ending index in entity array based on current type selected.
function getCurrentTypeEnd(level) {
var idx = getCurrentTypeIdx(level) + 1;
if (idx < typeStart[level].length) {
// Return one less than start of next span.
return typeStart[level][idx] - 1;
} else {
// Return index of last entity ID.
return entityIDs[level].length - 1;
}
}
// Set type at level.
function setCurrentType(level, typeValue) {
var typeCurrentFld = document.getElementById('_1_1_190_' + String(level) + '_191_1');
if (typeCurrentFld)
typeCurrentFld.value = typeValue;
}
// Get current Entity ID at level.
function getCurrentEntityID(level) {
var entityCurrentIDFld = document.getElementById('_1_1_190_' + String(level) + '_193_1');
if (entityCurrentIDFld)
return entityCurrentIDFld.value;
else
return '';
}
// Set entity ID and value at a level.
function setCurrentEntity(level, entityID, entityValue) {
var entityCurrentIDFld = document.getElementById('_1_1_190_' + String(level) + '_193_1');
var entityCurrentValFld = document.getElementById('_1_1_190_' + String(level) + '_192_1');
if (entityCurrentValFld && entityCurrentIDFld) {
entityCurrentIDFld.value = entityID;
entityCurrentValFld.value = entityValue;
}
// See if we should fill in the State and County fields (used in some messages in workflow). We will
// just get the data from levels 2 and 3 for State and Country (or Parish, etc.).
if (level == 2) {
var oldStateFld = document.getElementById('_1_1_10_1');
if (entityValue == '')
oldStateFld.value = ' '; // To avoid getting '?'
else
oldStateFld.value = entityValue;
}
if (level == 3) {
var oldCountyFld = document.getElementById('_1_1_11_1');
if (entityValue == '')
oldCountyFld.value = ' '; // To avoid getting '?'
else
oldCountyFld.value = entityValue;
}
}
// Given a level and an entity ID, determine number of children
function getNumberChildren(level, id) {
if (entityIDs[level] != null && entityNumChildren[level] != null && entityNumChildren[level].length == entityIDs[level].length) {
for (var i=0; i<entityIDs[level].length; i++) {
if (entityIDs[level][i] == id) {
return entityNumChildren[level][i];
}
}
}
return 0;
}
/*** Land Desription: View Functions - These all deal with the view, such as populating drop-downs. ***/
// Sets the location drop-downs to match the internal representation in arrays.
function populateDropdowns(start) {
for (var level=start; level<=50; level++) {
var levelSection = document.getElementById('level_1_1_190_' + String(level));
try {
if (levelSection) {
if (!populateTypeDropDown(level) || !populateEntityDropDown(level))
hideField(levelSection);
else
// If country level and only U.S. there, hide it.
if (getCurrentType(level).toUpperCase() == 'COUNTRY' &&
document.getElementById('entityselect_1_1_190_' + String(level)).length <= 2 ) {
hideField(levelSection);
} else {
showField(levelSection);
}
} else {
break;
}
}
catch(err)
{
// This should not happen but is here just in case.
alert('Runtime Error: '+err.message);
break;
}
}
}
// Populates the type drop-down at a level from the internal data representation.
// Returns true if success, false if level doesn't exist.
function populateTypeDropDown(level) {
var typeSelFld = document.getElementById('typeselect_1_1_190_' + String(level));
var typeFixedFld = document.getElementById('typefixed_1_1_190_' + String(level));
if (typeSelFld && typeFixedFld) {
if (typeValues[level] == null || typeValues[level].length == 0) {
typeSelFld.length = 0;
return false;
} else if (typeValues[level].length == 1) {
// Only one type at this level, so just make it a regular label, not a drop-down.
hideField(typeSelFld);
showField(typeFixedFld);
typeFixedFld.innerHTML = typeLabels[level][0];
setCurrentType(level, typeValues[level][0]); // Always reset current value if only one possible.
} else {
// Multiple types at this level, so have a drop-down so they can pick.
hideField(typeFixedFld);
showField(typeSelFld);
typeSelFld.length = typeValues[level].length;
// On level one, if no type set, default to State.
//if (level == 1 && getCurrentType(level) == '')
// setCurrentType(level, 'STATE');
var curType = getCurrentType(level);
for (var i=0; i<typeValues[level].length; i++) {
typeSelFld.options[i].value = typeValues[level][i];
typeSelFld.options[i].text = typeLabels[level][i];
if (typeValues[level][i] == curType)
typeSelFld.selectedIndex = i; // Set selected to current.
}
// Set the current type to the selected one in case it didn't get set above.
setCurrentType(level, typeSelFld.value);
}
return true;
} else {
// Should not happen, but just in case.
return false;
}
}
// Populates the entity drop-down at a level from the internal data representation.
// Returns true if success, false if level doesn't exist.
function populateEntityDropDown(level) {
var entitySelFld = document.getElementById('entityselect_1_1_190_' + String(level));
if (entitySelFld) {
entitySelFld.length = 1;
// If no data, drop-down will be empty.
if (entityValues[level] == null || entityValues[level].length == 0 ||
entityIDs[level] == null || entityIDs[level].length == 0) {
return false;
} else {
var startIdx = getCurrentTypeStart(level);
var endIdx = getCurrentTypeEnd(level);
var curType = getCurrentType(level).toUpperCase();
var curEntityID = getCurrentEntityID(level);
var aIdx, dIdx; // index of array and drop-down are different.
// Load drop-down from array data. Note that first entry in drop-down is always "-- Select --"
// with a value of null string.
entitySelFld.length = endIdx - startIdx + 2;
for (dIdx=1,aIdx=startIdx; aIdx <= endIdx; dIdx++,aIdx++) {
entitySelFld.options[dIdx].value = entityIDs[level][aIdx];
entitySelFld.options[dIdx].text = entityValues[level][aIdx];
if (entitySelFld.options[dIdx].value == curEntityID)
entitySelFld.selectedIndex = dIdx; // Set selected to current.
}
// Set the current entity to the selected one in case it didn't get set above.
if (entitySelFld.selectedIndex > 0)
setCurrentEntity(level, entitySelFld.value, entitySelFld.options[entitySelFld.selectedIndex].text);
else
setCurrentEntity(level, '', '');
}
return true;
} else {
// Should not happen, but just in case.
return false;
}
}
/*** Land Desription: Controller Functions - These control the Land Description data and view, and respond to user actions. ***/
// Load all the location drop-downs starting at row "start".
// If reset is true, reset to defaults, otherwise set to value stored.
// This works by loading each successive level first into the arrays, then into the drop-downs.
function loadAllLocations(start, reset) {
// If reset, clear all data from here on down.
if (reset) {
resetData(start);
}
// Load the data model, then populate the menus.
loadDataFrom(start, start);
}
// A Land Description type was changed.
function typeSelectionChanged(selObj) {
// Extract level number from object id "typeselect_1_1_190_<level>".
var level = selObj.id.split('_')[4];
if (!isNaN(level)) {
// Set the new type in the hidden form field. Also reset the current entity at this
// level in its hidden form field.
setCurrentType(level, selObj.value);
setCurrentEntity(level, '', '');
// Repopulate the entity drop-down.
populateEntityDropDown(level);
// Reload the levels under this one based on changes.
loadAllLocations(parseInt(level)+1, true);
}
}
// A Land Description value was changed.
function entitySelectionChanged(selObj) {
// Reset normal border.
normalborder(selObj);
// Extract level number from object id "entityselect_1_1_190_<level>".
var level = selObj.id.split('_')[4];
if (!isNaN(level)) {
// Set the new entity in the hidden form field.
setCurrentEntity(level, selObj.value, selObj.options[selObj.selectedIndex].text);
// Load drop-downs below this one based on new parent entity.
loadAllLocations(parseInt(level)+1, true);
}
}
/*** End Land Description section ***/
// Do form validation.
function validateForm()
{
try
{
// Need to add validation here.
var selectOperator=document.getElementById("_1_1_69_1_72_1");
var opAlsoShipperYes=document.getElementById("isOpShipper1");
var opAlsoShipperNo=document.getElementById("isOpShipper2");
var shipperName=document.getElementById("_1_1_61_1");
var wellName=document.getElementById("_1_1_5_1");
var isMultiWellYes=document.getElementById("isMultiWell1");
var isMultiWellNo=document.getElementById("isMultiWell2");
var additionalWells=document.getElementById("_1_1_29_1");
var assignEasementYes=document.getElementById("opAssignEasement1");
var assignEasementNo=document.getElementById("opAssignEasement2");
var estProduction=document.getElementById("_1_1_8_1");
var formation=document.getElementById("_1_1_155_1_156_1");
var fieldName=document.getElementById("_1_1_14_1");
var isWellStakedYes=document.getElementById("isWellStaked1");
var isWellStakedNo=document.getElementById("isWellStaked2");
var leaseTypeFld=document.getElementById("_1_1_186_1");
var leaseNumber=document.getElementById("_1_1_185_1");
var latitude=document.getElementById("_1_1_187_1");
var longitude=document.getElementById("_1_1_188_1");
var NAD=document.getElementById("_1_1_189_1");
var levelRow;
var entitySelFld;
// Operator required
if(selectOperator.selectedIndex <= 0)
{
alertAndHighlight(selectOperator,'You must select an Operator!');
return false;
}
// Operator also shipper question required.
if (!(opAlsoShipperYes.checked) && !(opAlsoShipperNo.checked))
{
alert('You must answer the "[LL_REPTAG_$OperatorAlsoShipperQ /]" question!');
return false;
}
// If Operator is not shipper, Shipper is required.
if (opAlsoShipperNo.checked && shipperName.value == '')
{
alertAndHighlight(shipperName,'You must enter a Shipper!');
return false;
}
// Well Name is required.
if (wellName.value == '')
{
alertAndHighlight(wellName,'You must enter a Well Name!');
return false;
}
// Estimated Production is required.
if (estProduction.value == '')
{
alertAndHighlight(estProduction,'You must enter estimated production!');
return false;
}
// Estimated Production must be numeric
if (isNaN(estProduction.value))
{
alertAndHighlight(estProduction, 'Estimated Production must be a number!');
return false;
}
// Validate location. All drop-downs presented must be filled.
for (var level=1; level<=50; level++) {
levelRow = document.getElementById('level_1_1_190_' + String(level));
entitySelFld = document.getElementById('entityselect_1_1_190_' + String(level));
// If row not defined, done.
if (!levelRow || !entitySelFld)
break;
// If row hidden, skip.
if (levelRow.style.display == 'none')
continue;
// If no entry selected, give error.
if(entitySelFld.selectedIndex == 0)
{
var entityType;
// Get name of label for error message.
var typeSelFld = document.getElementById('typeselect_1_1_190_' + String(level));
if (typeSelFld && typeSelFld.length > 0 && typeSelFld.style.display != 'none') {
entityType = typeSelFld.options[typeSelFld.selectedIndex].text;
} else {
var typeFld = document.getElementById('typefixed_1_1_190_' + String(level));
entityType = typeFld.innerHTML;
}
// Give error.
alertAndHighlight(entitySelFld,'You must select '+ entityType +'!');
return false;
}
}
// Latitude is required.
if (latitude.value == '')
{
alertAndHighlight(latitude,'You must enter latitude!');
return false;
}
// Latitude must be numeric.
if (isNaN(latitude.value))
{
alertAndHighlight(latitude, 'Latitude must be a number!');
return false;
}
// Longitude is required.
if (longitude.value == '')
{
alertAndHighlight(longitude,'You must enter longitude!');
return false;
}
// Longitude must be Numeric
if (isNaN(longitude.value))
{
alertAndHighlight(longitude, 'Longitude must be a number!');
return false;
}
// NAD required
if(NAD.selectedIndex <= 0)
{
alertAndHighlight(NAD,'You must select an NAD!');
return false;
}
// Lease Type is required.
if (leaseTypeFld.selectedIndex <= 0)
{
alertAndHighlight(leaseTypeFld,'You must select a lease type!');
return false;
}
// Lease number is required if lease type anything other than 'N/A' (ID=1).
if (leaseTypeFld.value > 1)
{
if (leaseNumber.value == '')
{
alertAndHighlight(leaseNumber,'You must enter a lease number!');
return false;
}
}
// Is Well Staked question required.
if (!(isWellStakedYes.checked) && !(isWellStakedNo.checked))
{
alert('You must answer the "[LL_REPTAG_$IsWellStakedQ /]" question!');
return false;
}
return true;
}
catch(err)
{
// Handle errors here. This ensures that a form does not get submitted because a run-time error
// occurred and crashed. Without the error trap, if that happens, validate returns true by default,
// which we don't want.
alert('Runtime Error: '+err.message);
return false;
}
}
// Make asterisk for lease number appear/disappear depending on value of lease type.
function leasetypeSelected(leaseTypeFld)
{
var leaseNumberRow = document.getElementById('leaseNumberRow');
var leaseNumberFld = document.getElementById('_1_1_185_1');
// Reset normal border.
normalborder(leaseTypeFld);
if (leaseTypeFld.value <= 1)
{
// Hide lease number and blank out if N/A or none.
hideField(leaseNumberRow);
leaseNumberFld.value = '';
} else {
// Show rlease number.
showField(leaseNumberRow);
}
}
</SCRIPT>
</head>
<body class="wcCenterAlignContent" onload="onInitPage();">
<form name="myForm" method="post" class="iceFrm" ACTION="[LL_CGIPATH /]" ENCTYPE="multipart/form-data" onsubmit="return validateForm();">
<INPUT TYPE="HIDDEN" NAME="func" VALUE="[LL_FUNC /]">
<INPUT TYPE="HIDDEN" NAME="LL_FUNC_VALUES" VALUE="[LL_FUNC_VALUES /]">
<INPUT TYPE="HIDDEN" NAME="LL_AttrFieldName" VALUE="">
<INPUT TYPE="HIDDEN" NAME="LL_AttrFieldIndex" VALUE="">
<INPUT TYPE="HIDDEN" NAME="LL_WFATTURL" VALUE="[LL_WFATTURL /]" id="wfatturl">
<!-- Hidden fields -->
<INPUT TYPE="hidden" NAME="_1_1_3_1" TITLE="requester" ID="_1_1_3_1" VALUE="[LL_REPTAG_USERID USERINFO:FULLNAME /]">
<INPUT TYPE="hidden" NAME="_1_1_77_1" TITLE="requester_email" ID="_1_1_77_1" VALUE="[LL_REPTAG_USERID USERINFO:MAILADDRESS /]">
<INPUT TYPE="hidden" NAME="_1_1_4_1" TITLE="requester_phone_number" ID="_1_1_4_1" VALUE="[LL_REPTAG_USERID USERINFO:CONTACT /]">
<!-- These get filled in by setOperatorName() function. -->
<input type="hidden" name="_1_1_69_1_70_1" title="OpName" id="_1_1_69_1_70_1" value="[LL_FormTag_1_1_69_1_70_1 /]" />
<!-- Old State and Country form attributes used to store level 2 & 3 data so we know where to get it in placeholders later. -->
<input type="hidden" name="_1_1_10_1" title="State" id="_1_1_10_1" value="[LL_FormTag_1_1_10_1 /]" />
<input type="hidden" name="_1_1_11_1" title="County" id="_1_1_11_1" value="[LL_FormTag_1_1_11_1 /]" />
<!-- Header -->
[LL_WEBREPORT_SUBWEBREPORT NODEID:[LL_REPTAG_$WCHeader-SWR /]
PARM:UserGuide:"External"
PARM:HeaderTitle:"Request a Well Connect"
/]
<!-- PAGE CONTENT -->
<TABLE WIDTH="100%" CELLSPACING="0" CELLPADDING="0" BORDER="0">
<TR><TD>
<TABLE WIDTH="81%" CELLSPACING="0" CELLPADDING="0" BORDER="0" align="center">
<!-- Header section -->
<TR>
<TD COLSPAN="2" CLASS="iceOutTxt" ALIGN="center" WRAP>
<a href="[LL_REPTAG_URLPREFIX /][LL_REPTAG_$MainMenuWR LLURL:REPORT /]">Return to Customer Menu</a>
</TD>
</TR>
<TR>
<TD COLSPAN="2"><IMG HEIGHT="12" ALT="" SRC="[LL_REPTAG_SUPPORTDIR /]spacer.gif" WIDTH="1" BORDER="0"></TD>
</TR>
<TR>
<TD COLSPAN="2" CLASS="iceOutTxt leftAlignl" WRAP>
Please enter the information below to create a well connect. All fields are required.
Please be sure you have all the information required before creating your request.
</TD>
</TR>
<TR>
<TD COLSPAN="2"><IMG HEIGHT="12" ALT="" SRC="[LL_REPTAG_SUPPORTDIR /]spacer.gif" WIDTH="1" BORDER="0"></TD>
</TR>
<TR>
<TD COLSPAN="2" CLASS="iceOutTxt leftAlignl" WRAP>
Please initiate a separate well connect request for each new well or group of new wells
on a single location that will require a separate, individual new meter.
</TD>
</TR>
<TR>
<TD COLSPAN="2"><IMG HEIGHT="12" ALT="" SRC="[LL_REPTAG_SUPPORTDIR /]spacer.gif" WIDTH="1" BORDER="0"></TD>
</TR>
<!-- Complete Well Name -->
<TR>
<TD CLASS="iceOutTxt" NOWRAP VALIGN="MIDDLE">
<span style="color: #CD0000;">*</span>Complete Well Name:
</TD>
<TD NOWRAP>
<INPUT CLASS="iceOutTxt" TYPE="text" NAME="_1_1_5_1" TITLE="Well_Name" ID="_1_1_5_1" VALUE="[LL_FormTag_1_1_5_1 /]"
ONKEYDOWN="normalborder(this);" SIZE="32" MAXLENGTH="100" ONCHANGE="markDirty();">
<button onclick="getWCdata()">WC Lookup</button>
</TD>
</TR>
<TR>
<TD COLSPAN="2"><IMG HEIGHT="6" ALT="" SRC="[LL_REPTAG_SUPPORTDIR /]spacer.gif" WIDTH="1" BORDER="0"></TD>
</TR>
<!-- Operator Name -->
<TR>
<TD CLASS="iceOutTxt" NOWRAP VALIGN="MIDDLE">
<span style="color: #CD0000;">*</span>Operator Name:
</TD>
<TD>
<select class="iceSelOneMnu" name="_1_1_69_1_72_1" title="Select Operator" id="_1_1_69_1_72_1" style="width:290px" onchange="setOperatorName();">
<option value="">--Select One--</option>
[LL_WEBREPORT_SUBWEBREPORT NODEID:[LL_REPTAG_$GetAllOperators-SWR /] PARM:Current:"[LL_FormTag_1_1_69_1_72_1 /]" /]
</select>
</TD>
</TR>
<TR>
<TD COLSPAN="2"><IMG HEIGHT="6" ALT="" SRC="[LL_REPTAG_SUPPORTDIR /]spacer.gif" WIDTH="1" BORDER="0"></TD>
</TR>
<!-- Is this operator also the shipper? -->
<TR id="IsOperatorShipper">
<TD CLASS="iceOutTxt" NOWRAP VALIGN="MIDDLE">
<span style="color: #CD0000;">*</span>[LL_REPTAG_$OperatorAlsoShipperQ /]
<a STYLE="text-decoration:none" class=wcHelpBubble href="#"><IMG SRC="[LL_REPTAG_SUPPORTDIR /]wellconnect/images/help.jpg" BORDER="0"><span STYLE="text-decoration:none">
<table width="100%" border="0"><tr><td>
If, as operator of the well, you will ship the gas under the same company name, please answer yes. If your interest in the gas from this well will ship under a company name that is different than the operator name, please answer no and provide the company name of the shipper in the space provided
</td></tr></table>
</span>
</a>
</TD>
<TD NOWRAP ALIGN="left">
<INPUT TYPE="radio" ID="isOpShipper1" name="_1_1_60_1" onclick="getradiovalues( )" value="Yes">Yes
<INPUT TYPE="radio" ID="isOpShipper2" name="_1_1_60_1" onclick="getradiovalues( )" value="No">No
</TD>
</TR>
<TR>
<TD COLSPAN="2"><IMG HEIGHT="6" ALT="" SRC="[LL_REPTAG_SUPPORTDIR /]spacer.gif" WIDTH="1" BORDER="0"></TD>
</TR>
<TR id="shipperNameRow">
<TD CLASS="iceOutTxt" NOWRAP VALIGN="MIDDLE" >
<span style="color: #CD0000;">*</span>Shipper Name:
</TD>
<TD NOWRAP>
<INPUT CLASS="iceOutTxt" TYPE="text" NAME="_1_1_61_1" TITLE="Shipper_Name" ID="_1_1_61_1" VALUE="[LL_FormTag_1_1_61_1 /]"
ONKEYDOWN="normalborder(this);" SIZE="32" MAXLENGTH="50" ONCHANGE="markDirty();">
</TD>
</TR>
<TR>
<TD COLSPAN="2"><IMG HEIGHT="6" ALT="" SRC="[LL_REPTAG_SUPPORTDIR /]spacer.gif" WIDTH="1" BORDER="0"></TD>
</TR>
<!-- Estimated production (in BBL) -->
<TR>
<TD CLASS="iceOutTxt" NOWRAP VALIGN="MIDDLE">
<span style="color: #CD0000;">*</span>Enter estimated production in BBL:
</TD>
<TD NOWRAP>
<INPUT CLASS="iceOutTxt" TYPE="text" NAME="_1_1_8_1" TITLE="Estimated_Production" ID="_1_1_8_1" VALUE="[LL_FormTag_1_1_8_1 /]"
ONKEYDOWN="normalborder(this);" SIZE="15" MAXLENGTH="15" ONCHANGE="markDirty();">
</TD>
</TR>
<TR>
<TD COLSPAN="2"><IMG HEIGHT="6" ALT="" SRC="[LL_REPTAG_SUPPORTDIR /]spacer.gif" WIDTH="1" BORDER="0"></TD>
</TR>
<!-- Land Description -->
<TR>
<TD CLASS="iceOutTxt" NOWRAP VALIGN="MIDDLE">
Location Description:
</TD>
<TD NOWRAP>
</TD>
</TR>
<TR>
<TD COLSPAN="2"><IMG HEIGHT="6" ALT="" SRC="[LL_REPTAG_SUPPORTDIR /]spacer.gif" WIDTH="1" BORDER="0"></TD>
</TR>
[LL_LOOP_BEGIN_1_1_190 /]
<tbody ID="level_1_1_190" style="display:none">
<TR>
<TD CLASS="iceOutTxt" NOWRAP VALIGN="MIDDLE">
<span style="color: #CD0000;">*</span><span id="typefixed_1_1_190" style="display:none"></span><select class="iceSelOneMnu" name="typeselect_1_1_190"
title="Select Type" id="typeselect_1_1_190" onchange="typeSelectionChanged(this);" style="display:none">
</select>:
<input type="hidden" name="_1_1_190_191_1" title="land_description_type" id="_1_1_190_191_1" value="[LL_FormTag_1_1_190_191_1 /]" />
</TD>
<TD NOWRAP>
<input type="hidden" name="_1_1_190_192_1" title="land_description_value" id="_1_1_190_192_1" value="[LL_FormTag_1_1_190_192_1 /]" />
<input type="hidden" name="_1_1_190_193_1" title="land_description_id" id="_1_1_190_193_1" value="[LL_FormTag_1_1_190_193_1 /]" />
<select class="iceSelOneMnu" name="entityselect_1_1_190" title="Select Location" id="entityselect_1_1_190" onchange="entitySelectionChanged(this);">
<option value="">--Select One--</option>
</select>
</TD>
</TR>
<TR>
<TD COLSPAN="2"><IMG HEIGHT="6" ALT="" SRC="[LL_REPTAG_SUPPORTDIR /]spacer.gif" WIDTH="1" BORDER="0"></TD>
</TR>
</tbody>
[LL_LOOP_END_1_1_190 /]
<!-- Additional Location Description -->
<TR>
<TD CLASS="iceOutTxt" NOWRAP VALIGN="MIDDLE">
Additional location description:
</TD>
<TD NOWRAP>
<INPUT CLASS="iceOutTxt" TYPE="text" NAME="_1_1_12_1" TITLE="Additional_Location_Description" ID="_1_1_12_1"
VALUE="[LL_FormTag_1_1_12_1 /]" SIZE="32" MAXLENGTH="254" ONCHANGE="markDirty();">
</TD>
</TR>
<TR>
<TD COLSPAN="2"><IMG HEIGHT="6" ALT="" SRC="[LL_REPTAG_SUPPORTDIR /]spacer.gif" WIDTH="1" BORDER="0"></TD>
</TR>
<!-- Latitude -->
<TR>
<TD CLASS="iceOutTxt" NOWRAP VALIGN="MIDDLE">
<span style="color: #CD0000;">*</span>Latitude:
</TD>
<TD NOWRAP>
<INPUT CLASS="iceOutTxt" TYPE="text" NAME="_1_1_187_1" TITLE="Latitude" ID="_1_1_187_1"
VALUE="[LL_FormTag_1_1_187_1 /]" ONKEYDOWN="normalborder(this);" SIZE="32" MAXLENGTH="32" ONCHANGE="markDirty();">
</TD>
</TR>
<TR>
<TD COLSPAN="2"><IMG HEIGHT="6" ALT="" SRC="[LL_REPTAG_SUPPORTDIR /]spacer.gif" WIDTH="1" BORDER="0"></TD>
</TR>
<!-- Longitude -->
<TR>
<TD CLASS="iceOutTxt" NOWRAP VALIGN="MIDDLE">
<span style="color: #CD0000;">*</span>Longitude:
</TD>
<TD NOWRAP>
<INPUT CLASS="iceOutTxt" TYPE="text" NAME="_1_1_188_1" TITLE="Longitude" ID="_1_1_188_1"
VALUE="[LL_FormTag_1_1_188_1 /]" ONKEYDOWN="normalborder(this);" SIZE="32" MAXLENGTH="32" ONCHANGE="markDirty();">
</TD>
</TR>
<TR>
<TD COLSPAN="2"><IMG HEIGHT="6" ALT="" SRC="[LL_REPTAG_SUPPORTDIR /]spacer.gif" WIDTH="1" BORDER="0"></TD>
</TR>
<!-- NAD -->
<TR>
<TD CLASS="iceOutTxt" NOWRAP VALIGN="MIDDLE">
<span style="color: #CD0000;">*</span>NAD:
</TD>
<TD>
<select class="iceSelOneMnu" name="_1_1_189_1" title="Select NAD" id="_1_1_189_1" onchange="normalborder(this)">
<option value="">--Select One--</option>
[LL_WEBREPORT_SUBWEBREPORT NODEID:[LL_REPTAG_$GetNADsOptions-SWR /] PARM:Current:"[LL_FormTag_1_1_189_1 /]" /]
</select>
</TD>
</TR>
<TR>
<TD COLSPAN="2"><IMG HEIGHT="6" ALT="" SRC="[LL_REPTAG_SUPPORTDIR /]spacer.gif" WIDTH="1" BORDER="0"></TD>
</TR>
<!-- Lease Type -->
<TR>
<TD CLASS="iceOutTxt" NOWRAP VALIGN="MIDDLE">
<span style="color: #CD0000;">*</span>Lease Type:
</TD>
<TD>
<select class="iceSelOneMnu" name="_1_1_186_1" title="lease_type" id="_1_1_186_1" onchange="leasetypeSelected(this);">
<option value="0">--Select One--</option>
[LL_WEBREPORT_SUBWEBREPORT NODEID:[LL_REPTAG_$WCLeaseType-SWR /] /]
</select>
</TD>
</TR>
<TR>
<TD COLSPAN="2"><IMG HEIGHT="6" ALT="" SRC="[LL_REPTAG_SUPPORTDIR /]spacer.gif" WIDTH="1" BORDER="0"></TD>
</TR>
<!-- Lease Number -->
<TR id="leaseNumberRow" style="display:none">
<TD CLASS="iceOutTxt" NOWRAP VALIGN="MIDDLE">
<span style="color: #CD0000;">*</span>Lease Number:
</TD>
<TD NOWRAP>
<INPUT CLASS="iceOutTxt" TYPE="text" NAME="_1_1_185_1" TITLE="Lease_Number" ID="_1_1_185_1" VALUE="[LL_FormTag_1_1_185_1 /]"
ONKEYDOWN="normalborder(this);" SIZE="32" MAXLENGTH="100" ONCHANGE="markDirty();">
</TD>
</TR>
<TR>
<TD COLSPAN="2"><IMG HEIGHT="6" ALT="" SRC="[LL_REPTAG_SUPPORTDIR /]spacer.gif" WIDTH="1" BORDER="0"></TD>
</TR>
<!-- Is Well Staked? -->
<TR>
<TD CLASS="iceOutTxt" NOWRAP VALIGN="MIDDLE">
<span style="color: #CD0000;">*</span>[LL_REPTAG_$IsWellStakedQ /]
<a class=wcHelpBubble href="#none"> <IMG SRC="[LL_REPTAG_SUPPORTDIR /]wellconnect/images/help.jpg" BORDER="0"><span>
<table width="100%"><tr><td>
Please answer yes if there are stakes physically in the ground for proposed well pad layout and access road, if applicable. Otherwise, please answer no.
</td></tr></table>
</span></a>
</TD>
<TD NOWRAP ALIGN="left">
<INPUT TYPE="radio" ID="isWellStaked1" name="_1_1_30_1" value="Yes">Yes
<INPUT TYPE="radio" ID="isWellStaked2" name="_1_1_30_1" value="No">No
</TD>
</TR>
</TABLE>
</TD></TR></TABLE>
<!-- ACTION BUTTONS -->
<div class="wcButtonContainer">
<input id="SaveButton" class="iceCmdBtn" value="Submit" type="submit" >
</div>
</div>
</form>
</body>
</html>
11-19-2013-5-03-24-PM.png11-19-2013-5-04-23-PM.png
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER