I really need help. I am a newbie programmer and really not sure how can i do this in joomla.
I need to create a pop up or iframe that pass variable from the parent page.
Basically what is to happen is this.
A user will enter a string in to a input box and click on search. When click on search button, a pop up will appear and allow him to select the closest match and return this chosen value back to the main page.
What i have done is something like that.
<input type="text" name="projectn" id="projectn" value="<?php echo $row->address?>" size="50" class="input-large" placeholder=" <?php echo JText::_('Project Name if any');?>" /> Enter to populate project info.
<input type="button" value="Search" onclick="JavaScript:makeSelection(this.form, document.getElementById('projectn').value);" />
In the makeSelection function it is like that.
function makeSelection(frm, proj) {
alert(proj);
if(!frm || !proj)
return;
targetElement = frm.elements[proj]
var handle = window.open('http://www.abc.com/abc/child.php?name='+proj, 'Project-Selection', 'width=300,height=200,location=no,menubar=no,status=no,scrollbar=yes,toolbar=no');
In the child.php page it is as follows
<?php
define( 'DS', DIRECTORY_SEPARATOR );
//get root folder
$rootFolder = explode(DS,dirname(__FILE__));
//current level in diretoty structure
$currentfolderlevel = 8;
array_splice($rootFolder,-$currentfolderlevel);
$base_folder = implode(DS,$rootFolder);
define( '_JEXEC', 1 );
if (file_exists(dirname(__FILE__) . '/defines.php')) {
include_once dirname(__FILE__) . '/defines.php';
}
if (!defined('_JDEFINES')) {
define('JPATH_BASE', dirname(__FILE__));
require_once JPATH_BASE.'../../../includes/defines.php';
}
require_once JPATH_BASE.'../../../configuration.php';
require_once JPATH_BASE.'../../../includes/framework.php';
require_once JPATH_BASE.'../../../includes/helper.php';
require_once JPATH_BASE.'../../../includes/toolbar.php';
require_once ( JPATH_BASE .DS.'libraries'.DS.'joomla'.DS.'factory.php' );
/* Create the Application */
$mainframe =& JFactory::getApplication('site');
$mainframe->initialise();
$mainframe->route();
$user =& JFactory::getUser();
$userid = $user->get('id');
?>
<?php
$a = $_GET['name'];
if($a != ""){
$db = JFactory::getDBO();
$db->setQuery("Select * from #__project where project_name like '%$a%'");
$prolists = $db->loadObject();
$npro = count($prolists);
echo $npro;
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv"Script-Content-Type" content="text/javascript">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Expires" content="0"> <!-- disable caching -->
<title>Example</title>
<script type="text/javascript">
function makeSlection(frm, proj) {
alert(proj);
/*if(!frm || !proj)
return;
var elem = frm.elements[proj];
if(!elem)
return;
var val = elem.options[elem.selectedIndex].value;
opener.targetElement.value = val;*/
this.close();
}
</script>
</head>
<body>
<form id="fsrm" name="fsrm" action="#">
<span>Names: </span>
<select name="nameSelection" id="nameSelection">
<option value="holly">Holly</option>
<option value="golly">Golly</option>
<option value="molly">Molly</option>
</select>
<input type="button" value="Select Name" onclick="JavaScript:makeSlection(this.form, document.getElementById('nameSelection').value);">
</form>
</body>
</html>
The problem now is the child page is not working and show this
No configuration file found and no installation code available. Exiting...
I am not sure why or somewhere is not correct. Most codes are sample codes found from the net so i am not sure how it should work.
What i need is a search button that pass a variable to a popup or a iframe, then in the popup it will access the database and give a list of values for user to choose. Once chosen, it will close the popup and pass the value back to the parent window.
Does anyone has any alternative or advise how this can be done? Thanks