Jump to content

Search the Community

Showing results for tags 'jqery'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 3 results

  1. In my database table, i have a field for price and quantity. Is there a way I could use a select to get 2 values from the database? What I mean is I will create a select field where when I select wholesale it will bring out the price and quantity and if I select retail, it will bring the price and the quantity.
  2. I am sorry, If I am asking a basic question.. I am working for a project where I need to give a upload and submit option for client. In that client will browse the local path and selects required "EXCEL" file and if they click to submit, then the content should be displayed in the webpage.. these are few codes I went through, but I thought I am not in the right way.. <HTML> <HEAD> <TITLE> PHP File Upload Script </TITLE> </HEAD> <BODY> <?php if( isset($_POST['submit1'])) { // $_FILES is the array auto filled when you upload a file and submit a form. $userfile_name = $_FILES['file1']['name']; // file name $userfile_tmp = $_FILES['file1']['tmp_name']; // actual location $userfile_size = $_FILES['file1']['size']; // file size $userfile_type = $_FILES['file1']['type']; // mime type of file sent by browser. PHP doesn't check it. $userfile_error = $_FILES['file1']['error']; // any error!. get from here // Content uploading. $file_data = ''; if ( !empty($userfile_tmp)) { // We encode the data just to make it more database friendly $file_data = base64_encode(@fread(fopen($userfile_tmp, 'r'), filesize($userfile_tmp))); } switch (true) { // Check error if any case ($userfile_error == UPLOAD_ERR_NO_FILE): case empty($file_data): echo 'You must select a document to upload before you can save this page.'; exit; break; case ($userfile_error == UPLOAD_ERR_INI_SIZE): case ($userfile_error == UPLOAD_ERR_FORM_SIZE): echo 'The document you have attempted to upload is too large.'; break; case ($userfile_error == UPLOAD_ERR_PARTIAL): echo 'An error occured while trying to recieve the file. Please try again.'; break; } if( !empty($userfile_tmp)) { // only MS office and text file is accepted. if( !(($userfile_type=="application/msword") || ($userfile_type=="text/plain") || ($userfile_type=="application/vnd.ms-excel")) ) {echo 'Your File Type is:'. $userfile_type; echo '<br>File type must be text(.txt) or msword(.doc).'; exit; } } echo filesize($userfile_tmp); } echo ?> <form name="profile" method="POST" action="<?php echo $_SERVER['PHP_SELF'] ?>" target="_self" enctype="multipart/form-data" > <P align ="center"><input type="hidden" name="MAX_FILE_SIZE" value="1000000"> <input type="file" name="file1" value="AttachFile" device="files" accept="text/*" tabindex=18 > <input type="submit" name="submit1" value="Submit" /> </P> </form> </BODY> </HTML> from the above code I am getting only file size.. This code will displays the content of excel file but it is a hard coded one, but I need client should select that file and content get displayed in the webpage itself... <?php error_reporting(E_ALL ^ E_NOTICE); require_once 'excel_reader2.php'; $data = new Spreadsheet_Excel_Reader("test.xls"); php echo $data->dump(true,true); ?> Thanks in advance...
  3. I have a form which allows the user to select ASC center and add students data for each time. The scenario is a user selects ASC center from the drop down list. Upon selecting the ASC center, a function called StudentList returns the students for the selected ASC center. Now these students should be populated for each row. I have assigned a class for the Student input field and used each function of the jquery to populate all the students field with the data returned by the StudentList function. But the problem is the data gets populated for the very first row correctly. But as soon as the user clicks on Add Student to add more student for a particular time or clicks on Add Time to add new time then the previously populated data gets cleared. The expected is that the once the ASC center is selected from the drop down by the user, then no matter how many new students or new time is added by the user on the form by clicking Add Student or Add Time button then the previously populated data should not be cleared. The below image shows the students populated for the first student row on selecting the ASC center https://pasteboard.co/PDm9UwYMK4CI.png Below is the image which shows the Students input field gets cleared when a user adds new student or adds new time https://pasteboard.co/fzUipa4ZYtCO.png Below is the function StudentList which returns the list of students for specific ASC center. public function actionStudentLists($id) { $countstudents = Student::find()->where(['ASCId' => $id])->count();//Counts number of students $Students = Student::find()->where(['ASCId' => $id])->all(); // Execute students for ASCId if ($countstudents > 0) { echo "<option value>Select Students</option>"; foreach ($Students as $Student) { ob_start(); echo "<option value='" . $Student->StudentId . "'>" . $Student->StudentName . "</option>"; } } else { echo "<option> - </option>"; } } Below is the form <?php use yii\helpers\Html; use yii\bootstrap\ActiveForm; use yii\jui\DatePicker; use wbraganca\dynamicform\DynamicFormWidget; use app\models\Ascassignment; use app\models\Asccenter; use kartik\time\TimePicker; use yii\helpers\ArrayHelper; use app\models\Student; ?> <script> // When user clicks on Add Student button $(function () { $(".dynamicform_student").on("beforeInsert", function(e, item) { $.post("index.php?r=student/student-lists&id=' . '"+$("select#ascteacherreport-ascid").val(),function(data){ $(".i").html(data); }); }); }); //When user clicks on Add Time button $(function () { $(".dynamicform_wrapper").on("beforeInsert", function(e, item) { $.post("index.php?r=student/student-lists&id=' . '"+$("select#ascteacherreport-ascid").val(),function(data){ $(".i").html(data); }); }); }); </script> <div class="ascteacherreport-form"> <?php $form = ActiveForm::begin(['id' => 'dynamic-form', 'options' => ['class' => 'disable-submit-buttons'], ]);?> <div class="panel panel-primary " > <div class="panel panel-heading"><font size="3"><b>Teacher Report</b></font></div> <div class="row"> <div class="col-sm-4"> <?= $form->field($model, 'ASCId')->dropDownList(ArrayHelper::map(Asccenter::find()->leftJoin('ascassignment','`ascassignment`.`ASCId`=`asccenter`.`ASCId`')->where(['ascassignment.UserId' => \Yii::$app->user->identity->getonlyid()])->all(),'ASCId','ASCName'), ['prompt' => 'Select ASC Center','class'=>'form-control ascid','onChange' => ' $.post("index.php?r=student/student-lists&id=' . '"+$(this).val(),function(data){ $(".i").each(function(k,v) { $(".i").html(data); // Populates the Student control having class .i with the data from the StudentList function } ); }); ' ]) ?> </div> <div class="col-sm-4"> <?= $form->field($model, 'DateofReport')->widget(DatePicker::classname(), [ //'language' => 'ru', 'dateFormat' => 'yyyy-MM-dd', 'options' => ['class' => 'form-control picker','readOnly'=>'readOnly'], 'clientOptions'=>['changeMonth'=>true, 'changeYear'=>true, 'readOnly'=>true] ]) ?> </div> </div> </div> <div class="panel panel-primary"> <div class="panel-heading"><font size="3"><b>Time and Student Details</b></font></div> <?php DynamicFormWidget::begin([ 'widgetContainer' => 'dynamicform_wrapper', 'widgetBody' => '.container-items', 'widgetItem' => '.time-item', 'limit' =>10, 'min' => 1, 'insertButton' => '.add-time', 'deleteButton' => '.remove-time', 'model' => $modelsTime[0], 'formId' => 'dynamic-form', 'formFields' => [ 'FromTime', 'ToTime' ], ]); ?> <table class="table table-bordered"> <thead> <tr bgcolor='#B8B8B8'> <th style='border: 1px solid black;'></th> <th class ="text-center" style='border: 1px solid black;'>Time</th> <th class ="text-center" style='border: 1px solid black;'>Student Details</th> <th class="text-center" style='border: 1px solid black;'> <button type="button" class="add-time btn btn-success btn-xs"><span class="fa fa-plus"></span> Add Time</button> </th> </tr> </thead> <tbody class="container-items"> <?php foreach ($modelsTime as $indexTime => $modelTime): ?> <tr class="time-item"> <td class="vcenter" style='border: 1px solid black;'> <?php // necessary for update action. if (! $modelTime->isNewRecord) { echo Html::activeHiddenInput($modelTime, "[{$indexTime}]ASCReportDetailsId"); } ?> </td> <td style='border: 1px solid black;width:15%'> <?= $form->field($modelTime, "[{$indexTime}]FromTime")->label(true)->widget(TimePicker::classname(),[ 'pluginOptions' => [ 'readOnly' => true, 'minuteStep' => 1, ],])?> <br> <?=$form->field($modelTime, "[{$indexTime}]ToTime")->label(true)->widget(TimePicker::classname(),[ 'pluginOptions' => [ 'readOnly' => true, 'minuteStep' => 1, ], ])?> </td> <td style='border: 1px solid black;'> <?= $this->render('_form-studentdata', [ 'form' => $form, 'indexTime' => $indexTime, 'modelsStudentdata' => $modelsStudentdata[$indexTime], ]) ?> </td> <td class="text-center vcenter" style='border: 1px solid black;'> <button type="button" class="remove-time btn btn-danger btn-xs"><span class="fa fa-minus"></span></button> </td> </tr> <?php endforeach; ?> </tbody> </table> <?php DynamicFormWidget::end(); ?> </div> <div class="form-group"> <?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> </div> <?php ActiveForm::end(); ?> </div> Below is the nested inner form Student form <?php use yii\helpers\Html; use yii\helpers\ArrayHelper; use yii\bootstrap\ActiveForm; //use nex\datepicker\DatePicker; use yii\web\UploadedFile; use wbraganca\dynamicform\DynamicFormWidget; use app\models\Student; ?> <?php DynamicFormWidget::begin([ 'widgetContainer' => 'dynamicform_student', 'widgetBody' => '.container-student', 'widgetItem' => '.student-item', 'limit' => 50, 'min' => 1, 'insertButton' => '.add-student', 'deleteButton' => '.remove-student', 'model' => $modelsStudentdata[0], 'formId' => 'dynamic-form', 'formFields' => [ 'StudentId', 'Subject', 'Topic', 'Confidence', ], ]); ?> <table class="table table-bordered"> <thead> <tr bgcolor='#B8B8B8'> <th style='border: 1px solid black;'></th> <th class ="text-center" style='border: 1px solid black;'>Student</th> <th class ="text-center" style='border: 1px solid black;'>Subject</th> <th class ="text-center" style='border: 1px solid black;'>Topic</th> <th class ="text-center" style='border: 1px solid black;'>Confidence</th> <th class="text-center" style='border: 1px solid black;'> <button type="button" class="add-student btn btn-success btn-xs"><span class="glyphicon glyphicon-plus"></span> Add Student</button> </th> </tr> </thead> <tbody class="container-student"> <?php foreach ($modelsStudentdata as $indexStudent => $modelStudentdata): ?> <tr class="student-item"> <td class="vcenter" style='border: 1px solid black;'> <?php // necessary for update action. if (! $modelStudentdata->isNewRecord) { echo Html::activeHiddenInput($modelStudentdata, "[{$indexTime}][{$indexStudent}]ASCTeacherReportTimeDetailsId"); } ?> </td> <td style='border: 1px solid black; width:30%'><?= $form->field($modelStudentdata, "[{$indexTime}][{$indexStudent}]StudentId")->label(false)->dropDownList(ArrayHelper::map(Student::find()->all(),'StudentId','StudentName'), ['prompt' => 'Select Student','class'=>'form-control i']) ?> //class .i assigned to the Student </td> <td style='border: 1px solid black; width:30%'> <?= $form->field($modelStudentdata, "[{$indexTime}][{$indexStudent}]Subject")->label(false)->textInput(['maxlength' => true]) ?> </td> <td style='border: 1px solid black; width:30%'> <?= $form->field($modelStudentdata, "[{$indexTime}][{$indexStudent}]Topic")->label(false)->textInput(['maxlength' => true]) ?> </td> <td style='border: 1px solid black; width:30%'> <?= $form->field($modelStudentdata, "[{$indexTime}][{$indexStudent}]Confidence")->label(false)->textInput(['maxlength' => true]) ?> </td> <td class="text-center vcenter" style=" border: 1px solid black;width: 90px;"> <button type="button" class="remove-student btn btn-danger btn-xs"><span class="glyphicon glyphicon-minus"></span></button> </td> </tr> <?php endforeach; ?> </tbody> </table> <?php DynamicFormWidget::end(); ?>
×
×
  • 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.