ritztech
asked on
Multiple Radios With Searchbox to functions toPHP_SELF (perform a script) issues
quick layout trying to accomplish
Radio Boxes
O O O O O O O
SEARCH
.............. -OK-
OK is the submit button
POST should be
radioX (function to run) +search
user select radiobox 4 and then searches xxxaaa then presses OK then POST PHP_SELF
same page being used (index.php)
im having an issue trying to get the radio to be selected with teh SEARCH then SUBMIT and RUN a function to perform with the DATA
//later looking at trying to view it as the script in the backend is running rather then waiting for it BUT thats just me a google to find lol
<?php
if (isset($_REQUEST['search'] )) {
$search = escapeshellcmd($_REQUEST[' search']);
$command = '/etc/SCRIPT/BLAHLOG ' . $search;
printCmd($command, true);
} ?>
<?php
if radio3 SELECTED THEN
$search = escapeshellcmd($_REQUEST[' search']);
$command = '/etc/SCRIPT/BLAHSQLscript ' . $search;
printCmd($command, true);
?>
<form>
<div id="radio">
<input type="radio" id="radio1" name="radio" /><label for="radio1">BLAhscript</l abel>
<input type="radio" id="radio2" name="radio" /><label for="radio2">BLAHTEST</lab el>
<input type="radio" id="radio3" name="radio" /><label for="radio3">BLAHSQLscript </label>
<input type="radio" id="radio4" name="radio" /><label for="radio4">BLAHTEST</lab el>
<input type="radio" id="radio5" name="radio" /><label for="radio5">BLAHREAD</lab el>
<input type="radio" id="radio6" name="radio" /><label for="radio6">BLAHLOG</labe l>
<input type="radio" id="radio7" name="radio" /><label for="radio7">BLAHUSAGE</la bel>
<input type="radio" id="radio8" name="radio" /><label for="radio8">BLAHNETWORK</ label>
<input type="radio" id="radio9" name="radio" /><label for="radio9">BLAH9</label>
<input type="radio" id="radio10" name="radio" /><label for="radio10">BLAH10</labe l>
</div>
</form>
<p> </p>
<p><strong>Enter a site:</strong>
<input type="text" name="search" id="search" />
<input type="submit" value="OK"/>
(PUT IT IN THE SAME PAGE from the response of RADIO4 selected ---PLUS ----SEARCH)
<div id="RESPONSE" style="width: 540px"></div>
Radio Boxes
O O O O O O O
SEARCH
.............. -OK-
OK is the submit button
POST should be
radioX (function to run) +search
user select radiobox 4 and then searches xxxaaa then presses OK then POST PHP_SELF
same page being used (index.php)
im having an issue trying to get the radio to be selected with teh SEARCH then SUBMIT and RUN a function to perform with the DATA
//later looking at trying to view it as the script in the backend is running rather then waiting for it BUT thats just me a google to find lol
<?php
if (isset($_REQUEST['search']
$search = escapeshellcmd($_REQUEST['
$command = '/etc/SCRIPT/BLAHLOG ' . $search;
printCmd($command, true);
} ?>
<?php
if radio3 SELECTED THEN
$search = escapeshellcmd($_REQUEST['
$command = '/etc/SCRIPT/BLAHSQLscript
printCmd($command, true);
?>
<form>
<div id="radio">
<input type="radio" id="radio1" name="radio" /><label for="radio1">BLAhscript</l
<input type="radio" id="radio2" name="radio" /><label for="radio2">BLAHTEST</lab
<input type="radio" id="radio3" name="radio" /><label for="radio3">BLAHSQLscript
<input type="radio" id="radio4" name="radio" /><label for="radio4">BLAHTEST</lab
<input type="radio" id="radio5" name="radio" /><label for="radio5">BLAHREAD</lab
<input type="radio" id="radio6" name="radio" /><label for="radio6">BLAHLOG</labe
<input type="radio" id="radio7" name="radio" /><label for="radio7">BLAHUSAGE</la
<input type="radio" id="radio8" name="radio" /><label for="radio8">BLAHNETWORK</
<input type="radio" id="radio9" name="radio" /><label for="radio9">BLAH9</label>
<input type="radio" id="radio10" name="radio" /><label for="radio10">BLAH10</labe
</div>
</form>
<p> </p>
<p><strong>Enter a site:</strong>
<input type="text" name="search" id="search" />
<input type="submit" value="OK"/>
(PUT IT IN THE SAME PAGE from the response of RADIO4 selected ---PLUS ----SEARCH)
<div id="RESPONSE" style="width: 540px"></div>
ASKER
one thing im trying to do is tie in onsubmit but dont know where to push an event trying to find code on google
OK, set the onsubmit attribute of your form :
with :
<form onsubmit="return doThingsBeforeSendingThePageToPHP()">
with :
function doThingsBeforeSendingThePageToPHP() {
// do what you want with the fields
// code
// code
// code
// code
// at the end return true to really submit (false if you want to stop the submission of the form
return true;
}
ASKER
snazzy that seems quicker ill have try it out
i thought the submit will go like in a PHP_SELF to the RESPONSE div so it will stay on the same page without going out to php?searchxx
<div id="RESPONSE" style="width: 540px">
function doThingsBeforeSendingThePa geToPHP() {
// do what you want with the fields
// code
// code
// code
// code
// at the end return true to really submit (false if you want to stop the submission of the form
return true;
}
</div>
i thought the submit will go like in a PHP_SELF to the RESPONSE div so it will stay on the same page without going out to php?searchxx
<div id="RESPONSE" style="width: 540px">
function doThingsBeforeSendingThePa
// do what you want with the fields
// code
// code
// code
// code
// at the end return true to really submit (false if you want to stop the submission of the form
return true;
}
</div>
the code provided is javascript not php. if you want to send something to php put it in an hidden field for example :
so :
and on the php side :
<input type="hidden" id="myHiddenFieldID" name="myHiddenFieldName" />
so :
function doThingsBeforeSendingThePageToPHP() {
document.getElementById("myHiddenFieldID").value = "something to send to PHP server code";
return true;
}
and on the php side :
<div id="RESPONSE" style="width: 540px">
<?PHP
$dataFromClientSide = $_REQUEST["myHiddenFieldName"];
// do things with this data sent from client side
?>
</div>
ASKER
do i throw this inside the DIV ID response
Should i look at calling functions somehow with building IF. onsubmit is clicked
RUN
radio1+search to function.....
im not sure where the hidden is but im using jquery for the radio boxes ...
when i changed radio to hidden it dissapeard the box
heres my Jquery for the Radio boxes to look all nice lol....
<div id="RESPONSE" style="width: 540px">
<?PHP
$dataFromClientSide = $_REQUEST["myHiddenFieldName"];
// do things with this data sent from client side
?>
<?php
if (isset($_REQUEST['radio6'])) {
$search = escapeshellcmd($_REQUEST['search']);
$command = '/etc/SCRIPT/BLAHLOG ' . $search;
printCmd($command, true);
} ?>
<?php
if (isset($_REQUEST['radio3'])) {
$search = escapeshellcmd($_REQUEST['search']);
$command = '/etc/SCRIPT/SQLsciprt' . $search;
printCmd($command, true);
?>
</div>
Should i look at calling functions somehow with building IF. onsubmit is clicked
RUN
radio1+search to function.....
im not sure where the hidden is but im using jquery for the radio boxes ...
when i changed radio to hidden it dissapeard the box
heres my Jquery for the Radio boxes to look all nice lol....
<link rel="stylesheet" type="text/css" media="all"
href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.11/themes/ui-darkness/jquery-ui.css"/>
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js">
</script>
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.11/jquery-ui.min.js">
</script>
<script>
$(function() {
$( "#radio" ).buttonset();
});
</script>
you can run anay code anywhere once you don't send any char with it.
so if printCmd($command, true); don't send any characters why not put it in the div
a hidden input is a like a textbox but you don't see it.
so if printCmd($command, true); don't send any characters why not put it in the div
a hidden input is a like a textbox but you don't see it.
ASKER
just one more question ....
do i put each radio with individual of these
<input type="hidden" id="myHiddenFieldID1" name="myHiddenFieldName" />
<input type="hidden" id="myHiddenFieldID2" name="myHiddenFieldName" />
<input type="hidden" id="myHiddenFieldID3" name="myHiddenFieldName" />
<input type="hidden" id="myHiddenFieldID5" name="myHiddenFieldName" />
<input type="hidden" id="myHiddenFieldID6" name="myHiddenFieldName" />
<input type="hidden" id="myHiddenFieldID7" name="myHiddenFieldName" />
<input type="hidden" id="myHiddenFieldID8" name="myHiddenFieldName" />
<input type="hidden" id="myHiddenFieldID9" name="myHiddenFieldName" />
<input type="hidden" id="myHiddenFieldID10" name="myHiddenFieldName" />
OR insted of using this
<p><strong>Enter Site/Market:</strong>
<input type="text" name="search" id="search" />
<input type="submit" value="OK"/>
</p>
<form id="form1" name="form1" method="post" action="">
<label for="search"></label>
</form>
do i put each radio with individual of these
<input type="hidden" id="myHiddenFieldID1" name="myHiddenFieldName" />
<input type="hidden" id="myHiddenFieldID2" name="myHiddenFieldName" />
<input type="hidden" id="myHiddenFieldID3" name="myHiddenFieldName" />
<input type="hidden" id="myHiddenFieldID5" name="myHiddenFieldName" />
<input type="hidden" id="myHiddenFieldID6" name="myHiddenFieldName" />
<input type="hidden" id="myHiddenFieldID7" name="myHiddenFieldName" />
<input type="hidden" id="myHiddenFieldID8" name="myHiddenFieldName" />
<input type="hidden" id="myHiddenFieldID9" name="myHiddenFieldName" />
<input type="hidden" id="myHiddenFieldID10" name="myHiddenFieldName" />
OR insted of using this
<p><strong>Enter Site/Market:</strong>
<input type="text" name="search" id="search" />
<input type="submit" value="OK"/>
</p>
<form id="form1" name="form1" method="post" action="">
<label for="search"></label>
</form>
I don't understand the purpose of the first one.
and where are you going to send something to server side with the second one?
and where are you going to send something to server side with the second one?
ASKER
im not to sure how the hidden works but what ever selected radio plus the search onclick submet
<link rel="stylesheet" type="text/css" media="all"
href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.11/themes/ui-darkness/jquery-ui.css"/>
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js">
</script>
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.11/jquery-ui.min.js">
</script>
<script>
$(function() {
$( "#radio" ).buttonset();
});
</script>
<body>
<div class="container">
<div class="header">
<div class="art-Logo">
<h1 id="name-text" class="art-Logo-name">SEVE R-Tools</a ></h1>
<div id="slogan-text" class="art-Logo-text"><spa n class="header">Tooools</sp an> </div>
</div>
</div>
<div class="sidebar1">
<ul class="nav">
<li><a href="index.php">Home</a>< /li>
<li><a href="index.php?page=alms" >Alarms</a ></li>
<li><a href="index.php?page=alas" >Clearvisi on</a></li >
<li><a href="#"> TEST</a></li>
<li><a href="#"> Testing</a></li>
<li><a href="#">alarms Check</a></li>
<li><a href="#">chkecks</a></li>
<li><a href="#">IP Subnet Calc</a></li>
<li><a href="#">RSL Tool</a></li>
</ul>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p><!-- end .sidebar1 --></p>
</div>
<div class="sidebarR">
<p><strong>LOGS</strong></ p>
<p> </p>
<p>(auto updates once every minute)</p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
</div>
<div class="content">
<p>
<?php
$page = $_GET['page'];
if($page)
{
include("inc/".$page.".php ");
}
else
{
echo " <p><strong>Select Script Below to Run</strong></p>";
}
?>
</p>
<div class="demo">
<form>
<div id="radio">
<p>
<input type="radio" id="radio1" name="radio" /> <label for="radio1">script1</labe l>
<input type="radio" id="radio2" name="radio" /> <label for="radio2">Script2</labe l>
<input type="radio" id="radio3" name="radio" /> <label for="radio3">Script3</labe l>
<input type="radio" id="radio4" name="radio" /> <label for="radio4">Script4</labe l>
<input type="radio" id="radio5" name="radio" /> <label for="radio5">Script5</labe l>
<input type="radio" id="radio6" name="radio" /> <label for="radio6">Script6</labe l>
</p>
<p>
<input type="radio" id="radio7" name="radio" /> <label for="radio7">Script7</labe l>
<input type="radio" id="radio8" name="radio" /> <label for="radio8">Script8</labe l>
<input type="radio" id="radio9" name="radio" /> <label for="radio9">Script9</labe l>
<input type="radio" id="radio10" name="radio" /> <label for="radio10">Script10</la bel>
<p> </p>
</div>
</form>
</div><!-- End demo -->
<p><strong>Enter Site/Market:</strong>
<input type="text" name="search" id="search" />
<input type="submit" value="OK"/>
</p>
<form id="form" name="form" method="post" action="">
<label for="search"></label>
</form>
<input type="hidden" id="myHiddenFieldID" name="myHiddenFieldName" />
<div id="RESPONSE" style="width: 400px">
<?PHP
$dataFromClientSide = $_REQUEST["search"];
// do things with this data sent from client side
?>
</div>
<p> </p>
</div>
<div class="footer">
<link rel="stylesheet" type="text/css" media="all"
href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.11/themes/ui-darkness/jquery-ui.css"/>
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js">
</script>
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.11/jquery-ui.min.js">
</script>
<script>
$(function() {
$( "#radio" ).buttonset();
});
</script>
<body>
<div class="container">
<div class="header">
<div class="art-Logo">
<h1 id="name-text" class="art-Logo-name">SEVE
<div id="slogan-text" class="art-Logo-text"><spa
</div>
</div>
<div class="sidebar1">
<ul class="nav">
<li><a href="index.php">Home</a><
<li><a href="index.php?page=alms"
<li><a href="index.php?page=alas"
<li><a href="#"> TEST</a></li>
<li><a href="#"> Testing</a></li>
<li><a href="#">alarms Check</a></li>
<li><a href="#">chkecks</a></li>
<li><a href="#">IP Subnet Calc</a></li>
<li><a href="#">RSL Tool</a></li>
</ul>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p><!-- end .sidebar1 --></p>
</div>
<div class="sidebarR">
<p><strong>LOGS</strong></
<p> </p>
<p>(auto updates once every minute)</p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
</div>
<div class="content">
<p>
<?php
$page = $_GET['page'];
if($page)
{
include("inc/".$page.".php
}
else
{
echo " <p><strong>Select Script Below to Run</strong></p>";
}
?>
</p>
<div class="demo">
<form>
<div id="radio">
<p>
<input type="radio" id="radio1" name="radio" /> <label for="radio1">script1</labe
<input type="radio" id="radio2" name="radio" /> <label for="radio2">Script2</labe
<input type="radio" id="radio3" name="radio" /> <label for="radio3">Script3</labe
<input type="radio" id="radio4" name="radio" /> <label for="radio4">Script4</labe
<input type="radio" id="radio5" name="radio" /> <label for="radio5">Script5</labe
<input type="radio" id="radio6" name="radio" /> <label for="radio6">Script6</labe
</p>
<p>
<input type="radio" id="radio7" name="radio" /> <label for="radio7">Script7</labe
<input type="radio" id="radio8" name="radio" /> <label for="radio8">Script8</labe
<input type="radio" id="radio9" name="radio" /> <label for="radio9">Script9</labe
<input type="radio" id="radio10" name="radio" /> <label for="radio10">Script10</la
<p> </p>
</div>
</form>
</div><!-- End demo -->
<p><strong>Enter Site/Market:</strong>
<input type="text" name="search" id="search" />
<input type="submit" value="OK"/>
</p>
<form id="form" name="form" method="post" action="">
<label for="search"></label>
</form>
<input type="hidden" id="myHiddenFieldID" name="myHiddenFieldName" />
<div id="RESPONSE" style="width: 400px">
<?PHP
$dataFromClientSide = $_REQUEST["search"];
// do things with this data sent from client side
?>
</div>
<p> </p>
</div>
<div class="footer">
ASKER
its running server side scripts like /usrbin/cat xxx or /usr/bin/bashscripts for log events with checking from a text box ..
ASKER
i saw something like this
<form id="searchForm" action="#">
<p>enter SITE
<input type="text" name="search" onkeypress="if (chkSubmit(event)) { FUNCTIONALL(); return false; }"/>
<input type="button" value="OK" onclick="FUNCTIONALL();" />
<img src="images/wait.gif" id="busy_indicator" alt="busy" style="visibility:hidden" />
</p>
</form>
could i do something inside FUNCTIONALL
IF radio4 was select then
enter this BIG IF with all my radio selections ?
<form id="searchForm" action="#">
<p>enter SITE
<input type="text" name="search" onkeypress="if (chkSubmit(event)) { FUNCTIONALL(); return false; }"/>
<input type="button" value="OK" onclick="FUNCTIONALL();" />
<img src="images/wait.gif" id="busy_indicator" alt="busy" style="visibility:hidden" />
</p>
</form>
could i do something inside FUNCTIONALL
IF radio4 was select then
enter this BIG IF with all my radio selections ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
i finally got it to work without Reloading the page
<form name="MyForm" action="response_normal.ph p" method="post" onsubmit="xmlhttpPost('res ponse_ajax .php', 'MyForm', 'RESPONSE', '<img src=\'pleasewait.gif\'>'); return false;">
<div id="RESPONSE" style="width: 400px">
response_ajax.php
<?php
$radio=$_POST['site'];
$search=$_POST['search'];
if ($radio == radio1)
{
// passthru('/usr/local/bin/s cript1 -w ' .$search);
$command=('/usr/local/bin/ script1 -w ' .$search);
$output=shell_exec($comman d);
print nl2br($output);
}
elseif ($radio == radio2)
{
//shell_exec('/usr/local/b in/script2 ' .$search);
$command=('/usr/local/bin/ script2 ' .$search);
$output=shell_exec($comman d);
print nl2br($output);
}
elseif ($radio == radio3)
{
only 1 thing im not to sure if it can be done say i have this below on radio3
and need to show it WHILE the script is running and not After the output is done
after googling quite a bit i saw proc_open but im not sure if the setup i have cause its going to another page screws it up...
print proc_open("ping -c 4 -i 1 4.2.2.2");
thanks
<form name="MyForm" action="response_normal.ph
<div id="RESPONSE" style="width: 400px">
response_ajax.php
<?php
$radio=$_POST['site'];
$search=$_POST['search'];
if ($radio == radio1)
{
// passthru('/usr/local/bin/s
$command=('/usr/local/bin/
$output=shell_exec($comman
print nl2br($output);
}
elseif ($radio == radio2)
{
//shell_exec('/usr/local/b
$command=('/usr/local/bin/
$output=shell_exec($comman
print nl2br($output);
}
elseif ($radio == radio3)
{
only 1 thing im not to sure if it can be done say i have this below on radio3
and need to show it WHILE the script is running and not After the output is done
after googling quite a bit i saw proc_open but im not sure if the setup i have cause its going to another page screws it up...
print proc_open("ping -c 4 -i 1 4.2.2.2");
thanks
Open in new window
$_REQUEST["radio"] will return the value of the selected radio