Jump to content

Recommended Posts

Hey there. I made this code in php. It now turns out that it has to be in JSP to work with my site. I'm trying to learn JSP but i'm really a beginner. Some help putting my php into JSP would be of great help.

 

session_start();
    /* /////////////////////////// Change Log ////////////////////////
     * 11/09/2011 - File Created
     */
    //get data from user submission
   $str = $_POST['order'];
   //remove extra whitespce to avoid unfilled array nodes
   $str = trim($str);
   //Explode the array based on  , and \n delemieters
   $array = explodeX(Array(",","\n"), $str);
   echo '<pre>';
   print_r($array);
   echo '</pre>';
   for($v=0;$v<=count($array);$v+=2){
       if($array[$v] == "" || $array[$v] == " "){
           header("Location:index.php");
       }
   }
   for($t=1;$t<=count($array);$t+=2){
       if(!is_numeric($array[$t])){
           header("Location:index.php");
       }
   }
   // form that will be automatically submitted without the user seeing
   echo '<form action="index.jsp?path=quickpadsummary" name="quickform" method="POST" onSubmit="loading(); return true;">';
        echo '<input type="hidden" name="qpitems" value="<%=forminputs%>">';
        echo '<input type="hidden" name="newsearch" value="true">';
        echo '<input type="hidden" name="path" value="quickpadsummary">';
       $f = 0;
       $l = 1;
       //echo theform inputs based on the array that was created
   for($p=0;$p<=(count($array)/2);$p++){
       echo '<input type="hidden" name="pnum'.$p.'" value="'.$array[$f].'">';
       echo '<input type="hidden" name="qty'.$p.'" value="'.$array[$l].'">';
       $f+=2;
       $l+=2;
   }
   
   echo '</form>';
  
   //java script to submit the form as soon as it loads.
   echo '<script type="text/javascript">';
   echo 'function myfunc () {';
   echo 'var frm = document.getElementById("quickform");';
   echo 'frm.submit();';
   echo '}';
   echo 'window.onload = myfunc;';
   echo '</script>'; 
    
   
   
function explodeX($delimiters,$string)
{
    $return_array = Array($string); // The array to return
    $d_count = 0;
    while (isset($delimiters[$d_count])) // Loop to loop through all delimiters
    {
        $new_return_array = Array();
        foreach($return_array as $el_to_split) // Explode all returned elements by the next delimiter
        {
            $put_in_new_return_array = explode($delimiters[$d_count],$el_to_split);
            foreach($put_in_new_return_array as $substr) // Put all the exploded elements in array to return
            {
                $new_return_array[] = $substr;
            }
        }
        $return_array = $new_return_array; // Replace the previous return array by the next version
        $d_count++;
    }
    return $return_array; // Return the exploded elements
}

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.