Jump to content
Larry Ullman's Book Forums

Search the Community

Showing results for tags 'textfield'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Single Editions
    • Modern Javascript: Develop and Design
    • The Yii Book
    • Effortless Flex 4 Development
    • Building a Web Site with Ajax: Visual QuickProject
    • Ruby: Visual QuickStart Guide
    • C++ Programming: Visual QuickStart Guide
    • C Programming: Visual QuickStart Guide
    • Adobe AIR: Visual QuickPro Guide
  • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (5th Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (4th Edition)
    • PHP 6 and MySQL 5 for Dynamic Web Sites: Visual QuickPro Guide (3rd Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (2nd Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (1st Edition)
  • PHP for the Web: Visual QuickStart Guide
    • PHP for the Web: Visual QuickStart Guide (5th Edition)
    • PHP for the Web: Visual QuickStart Guide (4th Edition)
    • PHP for the Web: Visual QuickStart Guide (3rd Edition)
    • PHP for the World Wide Web: Visual QuickStart Guide (2nd Edition)
    • PHP for the World Wide Web: Visual QuickStart Guide (1st Edition)
  • Effortless E-commerce with PHP and MySQL
    • Effortless E-Commerce with PHP and MySQL (2nd Edition)
    • Effortless E-Commerce with PHP and MySQL
  • PHP Advanced: Visual QuickPro Guide
    • PHP Advanced and Object-Oriented Programming: Visual QuickPro Guide (3rd Edition)
    • PHP 5 Advanced: Visual QuickPro Guide (2nd Edition)
    • PHP Advanced: Visual QuickPro Guide
  • MySQL: Visual QuickStart Guide
    • MySQL: Visual QuickStart Guide (2nd Edition)
    • MySQL: Visual QuickStart Guide (1st Edition)
  • Other
    • Announcements
    • Newsletter, Blog, and Other Topics
    • Forum Issues
    • Social

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Found 1 result

  1. Hello nice people, I'm pretty new to the 'Yii' platform, however, I have searched all over the internet for a solution to my problem as I have had a roadblock on this for 3 days (believe it). I have a created form to receive employee data from user input. I have a 'textField' for password but my intention is to auto-generate this password using a custom method call. This call will initially fill the 'textField' automatically upon page load and subsequently require the use of 'ajaxButton' to re-generate a new password. As it stands, the method is located in my Model, while my controller is set-up to manage the request and 'renderPartial' the targeted view upon the ajax request. Issue is, I have successfully achieved the effect because I can see the auto-generated value appear on a targeted 'div' in my form. However I want this value to appear within the 'textField' marked with a "password" attribute. Any ideas how I can achieve this, a clear and concise implementation will be appreciated as am still new to this MVC approach and not the best with javaScript either. the code below ----Model---- ---- Employee.php --- //Method for generating password in Employee Model ... // for simple character display (less secure default password) function simpleRandomizer($length){ $randstr = ""; for($i=0; $i<$length; $i++){ $randnum = mt_rand(0,61); if($randnum < 10){ $randstr .= chr($randnum+48); }else if($randnum < 36){ $randstr .= chr($randnum+55); }else{ $randstr .= chr($randnum+61); } } return $randstr; } // simpleRandomizer --- Controller---- --- EmployeeController.php public function actionRandomize(){ $model = new Employee(); // if(isset($_GET['ajax'])) $randomPassword = $model->simpleRandomizer(8); $this->renderPartial('randomize',array('random'=>$randomPassword)); } --- View ----- --- randomize.php --- /* @var $random EmployeeController */ echo CHtml::encode($random); --- form ---- --- _form --- //this code actually gets the value and updates the targeted div ('pass') as desired <div class="row" > <?php echo $form->labelEx($model,'password'); ?> <?php echo $form->textField($model,'password',array( 'id'=>"passwd", 'name'=>'passwd')); ?> <?php echo $form->error($model,'password'); ?> <?php echo CHtml::ajaxButton('Generate',array('randomize'),array( 'update'=>'#pass', )); ?> </div> <div id='pass'></div> // this is the alternate code i was hoping will actually target the textField ('password') and change its value // as desired <div class="row" > <?php echo $form->labelEx($model,'password'); ?> <?php echo $form->textField($model,'password',array( 'id'=>"passwd", 'name'=>'passwd')); ?> <?php echo $form->error($model,'password'); ?> <?php echo CHtml::ajaxButton('Generate',array('randomize'),array( 'update'=>'#pass', 'data'=>array('password'=>'js: { $(\'#passwd\').val()}'))); ?> </div> <div id='pass'></div>
×
×
  • Create New...