CS 142 Lecture Notes: FormsSlide 1 Simple Form Product: Price:

Slides:



Advertisements
Similar presentations
CS 142 Lecture Notes: EventsSlide 1 Access to Event Object ● event variable (HTML): ● Passed as argument to function (DOM/Firefox): element.onclick = mouseClick;
Advertisements

CS 142 Lecture Notes: FormsSlide 1 Simple Form Product: Price:
CS 142 Lecture Notes: Injection AttacksSlide 1 Unsafe Server Code advisorName = params[:form][:advisor] students = Student.find_by_sql( "SELECT students.*
Richard Fateman CS 282 Lecture eea1 Extended Euclidean Algorithm Lecture eea.
MA/CS 375 Fall MA/CS 375 Fall 2002 Lecture 29.
CS 221 Chapter 2 Excel. In Excel: A1 = 95 A2 = 95 A3 = 80 A4 = 0 =IF(A1
The Librarian Web Page Carol Wolf CS396X. Create new controller  To create a new controller that can manage more than just books, type ruby script/generate.
CS 142 Lecture Notes: Rails Controllers and ViewsSlide 1 Simple Rails Template
Lectures in Microeconomics-Charles W. Upton Applying Consumer Surplus.
Lectures in Microeconomics-Charles W. Upton More on Consumer Surplus.
Intelligent Information Retrieval CS 336 –Lecture 2: Query Language Xiaoyan Li Spring 2006 Modified from Lisa Ballesteros’s slides.
CS 142 Lecture Notes: FormsSlide 1 Simple Form Value1: Value2:
Lectures in Microeconomics-Charles W. Upton Consumer and Producer Surplus.
Price policy interventions in a large open economy Lecture 17. Economics of Food Markets Alan Matthews.
CS 142 Lecture Notes: FormsSlide 1 Draggable Rectangle #div1 { position: absolute; }...
Lectures in Microeconomics-Charles W. Upton Consumer Surplus.
Lectures in Microeconomics-Charles W. Upton Tax Rates and DWL.
CS 142 Lecture Notes: FormsSlide 1 Simple Form Value1: Value2:
AJAX (Asynchronous JavaScript and XML) Amit Jain CS 590 – Winter 2008.
CS 142 Lecture Notes: FormsSlide 1 AJAX Basics xhr = new XMLHttpRequest(); xhr.onreadystatechange = xhrHandler(); xhr.open("POST", url); xhr.send(postData);...
ADVERTISE THIS! Our Product Name: Price: Where to buy it: How to use it and good points:
CS212: Object Oriented Analysis and Design Lecture 10: Copy constructor-II.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 16 Introduction to Ajax.
Dynamic Pages – Quiz #11 Feedback (under assignments) Lecture Code:
Practice slides for Chapter 5 test
Recursive Descent Parsers Lecture 6 Mon, Feb 2, 2004.
OBJECTIVES 1.Simple present tense in questions, negative and affirmative 2.Use of HAVE 3.The possessive adjectives.
CS 142 Lecture Notes: FormsSlide 1 Simple Form Product: Price:
CSE 591: Energy-Efficient Computing Lecture 4 SLEEP: full-system Anshul Gandhi 347, CS building
PRG 420 Week 4 Individual Write a simple commission calculation program using IDE. To purchase this material click below link
CS SQL.
Website: Contact No: ID:
مهارتهای آموزشی و پرورشی ( روشها و فنون تدریس) تالیف: دکتر حسن شعبانی.
Web Systems Development (CSC-215)
پروتكل آموزش سلامت به مددجو
YG - CS170.
Challenge-Response Authentication
What is the Goal of Marketing?
البيئة السياسية للإدارة الدولية
CS 142 Lecture Notes: Rails Controllers and Views
CS 140 Lecture Notes: Protection
CS 140 Lecture Notes: Protection
CS 140 Lecture Notes: Virtual Machines
Reaction time زمن الرجع.
CS-401 Computer Architecture & Assembly Language Programming
CS 140 Lecture Notes: Protection
Last time Analysis vs Design General tasks for analysis
Lecture 9_1 George Koutsogiannakis
CS 140 Lecture Notes: Demand Paging
Augmented assignment operators Taken from notes by Dr. Neil Moore
CS 140 Lecture Notes: Introduction
CS 140 Lecture Notes: Protection
CS-401 Assembly Language Programming
CS 140 Lecture Notes: Demand Paging
Objective: To know the equations of simple straight lines.
Log Structure log index term leader Server 1 command
DiGraph Definitions Adjacency Matrix Adjacency List
Challenge-Response Authentication
CS148 Introduction to Programming II
CS 140 Lecture Notes: Protection
CS 140 Lecture Notes: Introduction
Lecture 18 Bottom-Up Parsing or Shift-Reduce Parsing
Engine Part ID Part 1.
Engine Part ID Part 2.
Engine Part ID Part 2.
CS 140 Lecture Notes: Virtual Machines
Modified at -
Lecture 7: JavaScript/DOM Lab Wednesday February 7, 2018.
Objective: To know the equations of simple straight lines.
Presentation transcript:

CS 142 Lecture Notes: FormsSlide 1 Simple Form Product: Price:

CS 142 Lecture Notes: FormsSlide 2 Rails Form Helpers {:action => :modify, :id do |form| %> <input id="student_name" name="student[name]“ size="30" type="text" value="Chen" /> <input id="student_birth" name="student[birth]“ size="30" type="text" value=" " /> <input name="commit" type="submit“ value="Modify Student" /> Describes type, provides initial values Object representing form

CS 142 Lecture Notes: FormsSlide 3 Customize Format {:action => :modify, :id do |form| %>...

CS 142 Lecture Notes: FormsSlide 4 Post Action Method def = Student.find(params[:id]) then redirect_to(:action => :show) else render(:action => :edit) end Hash with all of form data Redirects on success Redisplay form on error

CS 142 Lecture Notes: FormsSlide 5 Validation (in Model) class Student < ActiveRecord::Base validates_format_of :birth, :with => /\d\d\d\d-\d\d-\d\d/, :message => "must have format YYYY-MM-DD" def validate_gpa if (gpa 4.0) then errors.add(:gpa, "must be between 0.0 and 4.0") end validate :validate_gpa end Custom validation method Built-in validator Saves error info

CS 142 Lecture Notes: FormsSlide 6 Error Messages :url => {:action => :modify, :id do |form| %>......

CS 142 Lecture Notes: FormsSlide 7 File Uploads with Rails {:multipart => true} :url => {...}) do |form| %> In form post method: params[:student][:photo].read() params[:student][:photo].original_filename

CS 142 Lecture Notes: CookiesSlide 8