RsFormPro get a form field selected value and pass to another field
Budget: $8 – $15 USD
Dear Sirs
(1) Name : sch_id ; Additional Attributes : onclick="myFunction()"
Note : Items : is generate by php as below code
//<code>
// Prepare the empty array
$items = array();
// Prepare the database connection
$db = JFactory::getDbo();
// Keep this if you'd like a "Please select" option, otherwise comment or remove it
$items[] = "|Please Select[c]";
// Run the SQL query and store it in $results
$db->setQuery("SELECT id, name_en FROM #__ad_scheduler ORDER BY id ASC"); .......
(2) Form Fields : HTML Layout , I add a Ajax Example AND it works
<script>
var xmlhttp;
function loadXMLDoc(url,cfunc)
{ if (window.XMLHttpRequest) {
xmlhttp=new XMLHttpRequest();
} else {
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=cfunc;
xmlhttp.open("GET",url,true);
xmlhttp.send();
}
function myFunction()
{ loadXMLDoc("/modules/aRsFormPro/ajax_info.txt",function()
{ if (xmlhttp.readyState==4 && xmlhttp.status==200)
{ document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
}
});
}
</script>
<div id="myDiv"><h2>Display AJAX Content here</h2></div>
<button type="button" onclick="myFunction()">DIsplay Text</button>
MY QUESTION IS
HOW can I get the sch_id.value before submission
something likes $asch_id = ['form']['sch_id'].value;
that I can use $asch_id at another field Name : item_id
//<code>
// Prepare the empty array
$asch_id = 6; <=== the 6 is manually input, I need to get the selected item from Name = sch_id
$items = array();
// Prepare the database connection
$db = JFactory::getDbo();
// Keep this if you'd like a "Please select" option, otherwise comment or remove it
$items[] = "|Please Select[c]";
// Run the SQL query and store it in $results
$db->setQuery("SELECT id, name_en FROM #__ad_item WHERE sch_id = $asch_id ORDER BY name_en ASC");
$results = $db->loadObjectList();
(1) Name : sch_id ; Additional Attributes : onclick="myFunction()"
Note : Items : is generate by php as below code
//<code>
// Prepare the empty array
$items = array();
// Prepare the database connection
$db = JFactory::getDbo();
// Keep this if you'd like a "Please select" option, otherwise comment or remove it
$items[] = "|Please Select[c]";
// Run the SQL query and store it in $results
$db->setQuery("SELECT id, name_en FROM #__ad_scheduler ORDER BY id ASC"); .......
(2) Form Fields : HTML Layout , I add a Ajax Example AND it works
<script>
var xmlhttp;
function loadXMLDoc(url,cfunc)
{ if (window.XMLHttpRequest) {
xmlhttp=new XMLHttpRequest();
} else {
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=cfunc;
xmlhttp.open("GET",url,true);
xmlhttp.send();
}
function myFunction()
{ loadXMLDoc("/modules/aRsFormPro/ajax_info.txt",function()
{ if (xmlhttp.readyState==4 && xmlhttp.status==200)
{ document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
}
});
}
</script>
<div id="myDiv"><h2>Display AJAX Content here</h2></div>
<button type="button" onclick="myFunction()">DIsplay Text</button>
MY QUESTION IS
HOW can I get the sch_id.value before submission
something likes $asch_id = ['form']['sch_id'].value;
that I can use $asch_id at another field Name : item_id
//<code>
// Prepare the empty array
$asch_id = 6; <=== the 6 is manually input, I need to get the selected item from Name = sch_id
$items = array();
// Prepare the database connection
$db = JFactory::getDbo();
// Keep this if you'd like a "Please select" option, otherwise comment or remove it
$items[] = "|Please Select[c]";
// Run the SQL query and store it in $results
$db->setQuery("SELECT id, name_en FROM #__ad_item WHERE sch_id = $asch_id ORDER BY name_en ASC");
$results = $db->loadObjectList();