change select BOX to Input Box
Below part of code of .
Below codes shows drop down/select box, when option is selected it is redirected to the url.
What i would like to do is i like input box instead drop down/select box. USer can enter title ( option of dropdown/select box) manually.
PHP Code:
$query = "SELECT j.* FROM #__weblinks j inner join #__categories jc on j.catid = jc.id where $cat j.published='1' AND jc.published='1' ORDER BY $orderStr";
$db->setquery($query);
$rows=$db->loadObjectList();
error_reporting(E_ERROR);
$url = $_SERVER['SERVER_URI'];
echo "<form action='" . $url . "' method='post' >";
echo "<select style='display:none' name='add' id='add'";
if ($autodirect == 1)
{
echo " onChange='this.form.elements";
echo "[\"submit\"].click();' />";
}
else
{
echo " />";
}
if ($blank == '1')
echo "<option value='' />";
if ($custom != '')
{
echo "<option value='' />".$custom;
if ($separator != '')
echo "<option value='' />".str_repeat($separator,strlen($custom));
}
foreach ($rows as $row)
{
echo "<option value='" .$row->url. "' /> ". $row->title;
}
echo "</select>";
Any Help will be highly appreciated..:)
Ramesh chaudhary
Re: change select BOX to Input Box
Code:
<input type="text" name="myInputBox" />
That's all you need to add, it isn't quite clear what this form is doing so ill let you do it yourself but yea that's pretty much and input box just not sure where you need it added.
Re: change select BOX to Input Box
Quote:
Originally Posted by
SharpCode
Code:
<input type="text" name="myInputBox" />
That's all you need to add, it isn't quite clear what this form is doing so ill let you do it yourself but yea that's pretty much and input box just not sure where you need it added.
Thank you very much Sharp Code
<input type="text" name="myInputBox" /> will not work.
Below is complete php code.
I only want to input box instead select box, where title can be entered manually instead selecting from drop down option.
PHP Code:
<?php
defined('_JEXEC') or die ('Direct Access is not allowed');
$allweblinks = intval($params->get('allweblinks',0));
$golabel = $params->get('buttonname','Go');
$blank = intval($params->get('firstblank',0));
$custom = $params->get('firsttext','');
$separator = $params->get('separator','');
$image = $params->get('buttonimage','-1');
$catname = strtolower($params->get('catname','jumplinks'));
$autodirect = intval($params->get('autodirect',0));
if (isset($_POST['submit']) || isset($_POST['submit_x']))
{
$link = $_POST['add'];
$target = $params->get('target','parent');
switch ($target)
{
case 'parent':
echo "<meta http-equiv='Refresh' content='0;URL=" .$link. "' />";
break;
case 'newwith':
echo "<meta http-equiv='Refresh' content='0;URL=" .$_SERVER["PHP_SELF"]. "' />";
echo "<script type='text/javascript'>window.open('".$link."');</script>";
break;
case 'newwithout':
echo "<meta http-equiv='Refresh' content='0;URL=" .$_SERVER["PHP_SELF"]. "' />";
echo "<script type='text/javascript'>window.open('".$link."','',config='toolbar=no');</script>";
break;
}
exit();
}
$db = JFactory::getDBO();
$cat = "lower(jc.title) = '".$catname."' AND ";
if ($allweblinks == '1')
$cat = '';
$order = $params->get('order',0);
switch ($order)
{
case 0:
$orderStr = "ordering";
break;
case 1:
$orderStr = "j.title ASC";
break;
case 2:
$orderStr = "j.title DESC";
}
$query = "SELECT j.* FROM #__weblinks j inner join #__categories jc on j.catid = jc.id where $cat j.published='1' AND jc.published='1' ORDER BY $orderStr";
$db->setquery($query);
$rows=$db->loadObjectList();
error_reporting(E_ERROR);
$url = $_SERVER['SERVER_URI'];
echo "<form action='" . $url . "' method='post' >";
echo "<select style='display:none' name='add' id='add'";
if ($autodirect == 1)
{
echo " onChange='this.form.elements";
echo "[\"submit\"].click();' />";
}
else
{
echo " />";
}
if ($blank == '1')
echo "<option value='' />";
if ($custom != '')
{
echo "<option value='' />".$custom;
if ($separator != '')
echo "<option value='' />".str_repeat($separator,strlen($custom));
}
foreach ($rows as $row)
{
echo "<option value='" .$row->url. "' /> ". $row->title;
}
echo "</select>";
if ($autodirect == 1)
{
$style="style='visibility:hidden'";
}
if ($image !=-1 )
{
if ($autodirect ==1)
echo "<input type='submit' ".$style." id='submit' name='submit' value='".$golabel."' />";
$image = 'images/stories/'.$image;
echo "<input type='image' " .$style." src='".$image."' id='submit' name='submit' alt='".$golabel."' />";
}
else
{
echo "<input type='submit' ".$style." id='submit' name='submit' value='".$golabel."' />";
}
echo "</form>";
?>
Re: change select BOX to Input Box
Still my problem is not solved. Is there somebody who can help me out ....
Re: change select BOX to Input Box
Quote:
Originally Posted by
RameshChaudhary
Still my problem is not solved. Is there somebody who can help me out ....
What do you mean it doesn't work? The code "Sharp Code" gave you is the correct code for an input box.
Re: change select BOX to Input Box
Your problem can be solved very simply.
1. Stop using echo to output HTML. PHP is designed to be embedded in HTML, not vice versa. Your code is virtually unreadable.
2. Read this web page:
http://w3schools.com/html/html_forms.asp