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</label>
   <input type="radio" id="radio2" name="radio" /><label for="radio2">BLAHTEST</label>
   <input type="radio" id="radio3" name="radio" /><label for="radio3">BLAHSQLscript</label>
        <input type="radio" id="radio4" name="radio" /><label for="radio4">BLAHTEST</label>
        <input type="radio" id="radio5" name="radio" /><label for="radio5">BLAHREAD</label>
        <input type="radio" id="radio6" name="radio" /><label for="radio6">BLAHLOG</label>
        <input type="radio" id="radio7" name="radio" /><label for="radio7">BLAHUSAGE</label>
        <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</label>
       
       
   </div>
</form>
   
    <p>&nbsp;</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>
ritztechAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

leakim971PluritechnicianCommented:
set the value for each radio too :
    <input type="radio" id="radio1" name="radio" value="radio1" /><label for="radio1">BLAhscript</label>
    <input type="radio" id="radio2" name="radio" value="radio2" /><label for="radio2">BLAHTEST</label>
    <input type="radio" id="radio3" name="radio" value="radio3" /><label for="radio3">BLAHSQLscript</label>
    <input type="radio" id="radio4" name="radio" value="radio4" /><label for="radio4">BLAHTEST</label>
    <input type="radio" id="radio5" name="radio" value="radio5" /><label for="radio5">BLAHREAD</label>
    <input type="radio" id="radio6" name="radio" value="radio6" /><label for="radio6">BLAHLOG</label>
    <input type="radio" id="radio7" name="radio" value="radio7" /><label for="radio7">BLAHUSAGE</label>
    <input type="radio" id="radio8" name="radio" value="radio8" /><label for="radio8">BLAHNETWORK</label>
    <input type="radio" id="radio9" name="radio" value="radio9" /><label for="radio9">BLAH9</label>
    <input type="radio" id="radio10" name="radio" value="radio10" /><label for="radio10">BLAH10</label>

Open in new window


$_REQUEST["radio"] will return the value of the selected radio
0
ritztechAuthor Commented:
one thing im trying to do is tie in onsubmit but dont know where to push an event trying to find code on google
0
leakim971PluritechnicianCommented:
OK, set the onsubmit attribute of your form :

<form onsubmit="return doThingsBeforeSendingThePageToPHP()">

Open in new window


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;
}

Open in new window

0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

ritztechAuthor Commented:
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 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;
}

</div>
0
leakim971PluritechnicianCommented:
the code provided is javascript not php. if you want to send something to php put it in an hidden field for example :
<input type="hidden" id="myHiddenFieldID" name="myHiddenFieldName" />

Open in new window


so :
function doThingsBeforeSendingThePageToPHP() {
   document.getElementById("myHiddenFieldID").value = "something to send to PHP server code";
   return true;
}

Open in new window


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>

Open in new window

0
ritztechAuthor Commented:
do i throw this inside the DIV ID response


<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>

Open in new window


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>

Open in new window

0
leakim971PluritechnicianCommented:
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.

0
ritztechAuthor Commented:
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>
   
0
leakim971PluritechnicianCommented:
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?

0
ritztechAuthor Commented:
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">SEVER-Tools</a></h1>
      <div id="slogan-text" class="art-Logo-text"><span class="header">Tooools</span>    </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">Clearvision</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>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p><!-- end .sidebar1 --></p>
  </div>
 
  <div class="sidebarR">
 
    <p><strong>LOGS</strong></p>

<p>&nbsp;</p>
    <p>(auto updates once every minute)</p>
<p>&nbsp;</p>
    <p>&nbsp;</p>
<p>&nbsp;</p>
    <p>&nbsp;</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</label>
              <input type="radio" id="radio2" name="radio" />              <label for="radio2">Script2</label>
              <input type="radio" id="radio3" name="radio" />              <label for="radio3">Script3</label>
              <input type="radio" id="radio4" name="radio" />              <label for="radio4">Script4</label>
              <input type="radio" id="radio5" name="radio" />              <label for="radio5">Script5</label>
              <input type="radio" id="radio6" name="radio" />              <label for="radio6">Script6</label>
            </p>
            <p>
              <input type="radio" id="radio7" name="radio" />              <label for="radio7">Script7</label>
              <input type="radio" id="radio8" name="radio" />              <label for="radio8">Script8</label>
              <input type="radio" id="radio9" name="radio" />              <label for="radio9">Script9</label>
              <input type="radio" id="radio10" name="radio" />          <label for="radio10">Script10</label>
      
<p>&nbsp;</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>&nbsp;</p>

  </div>
  <div class="footer">
 


0
ritztechAuthor Commented:
its running server side scripts like /usrbin/cat xxx or /usr/bin/bashscripts  for log events with checking from a text box ..

0
ritztechAuthor Commented:
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();" />
      &nbsp;<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 ?
0
leakim971PluritechnicianCommented:
I understand your original need was to send the value of the selected radio button.
Just before sending the form to server side (where PHP run) we put the selected radio value in an hidden field
you don't need to create a hidden field for each radio button

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ritztechAuthor Commented:
i finally got it to work without Reloading the page

<form name="MyForm" action="response_normal.php" method="post" onsubmit="xmlhttpPost('response_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/script1 -w ' .$search);
 $command=('/usr/local/bin/script1 -w ' .$search);
$output=shell_exec($command);
print nl2br($output);

}
elseif ($radio == radio2)
{
      //shell_exec('/usr/local/bin/script2 ' .$search);
      
       $command=('/usr/local/bin/script2 ' .$search);
$output=shell_exec($command);
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
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.