SlideShare a Scribd company logo
Creating Smarter Interfaces with jQuery Amit Asaravala www.returncontrol.com [email_address]
What We’ll Cover Examples: Dynamic navigation More dynamic nav (or less?) Dynamic form components Popup calendars Multipart forms Learn: How jQuery works with Drupal Tips / techniques / tools
Example 1: Dynamic Nav Expanding / Collapsing Nav Menus Nice Menus module
Tip 1: Look for Existing Modules First LOTS  o’ options for dynamic menus: Nice Menus Simple Menu Active Menus DHTML Menu Lucid Menu Quick Menu CC-Remix-NC http://www.flickr.com/photos/b-tal/163450213/
Back to Example 1: Nice Menus Mostly CSS But uses jQuery to provide IE6 support
Technique: The Process Let Drupal know about JavaScript / jQuery In a module Or in a theme (template / function) Write the JavaScript Find the component(s) you want to modify Determine what actions to apply
1. Let Drupal Know Nice Menus notifies Drupal in the module uses drupal_set_html_head()   http://api.drupal.org/api/function/drupal_set_html_head Other option is drupal_add_js()  http://api.drupal.org/api/function/drupal_add_js
In nice_menus.module * function nice_menus_init() { drupal_set_html_head(' <!--[if IE]> <script type=&quot;text/javascript&quot; src=&quot;'. check_url(base_path() . 'misc/jquery.js') .'&quot;></script> <script type=&quot;text/javascript&quot; src=&quot;'. check_url(base_path() . 'misc/drupal.js') .'&quot;></script> <script type=&quot;text/javascript&quot; src=&quot;'. check_url(base_path() . drupal_get_path('module', 'nice_menus') .' /nice_menus.js ') .'&quot;></script> <![endif]--> '); … } * simplified
2. Write the JavaScript In nice_menus.js * * simplified $(document).ready(function() { $(&quot; ul.nice-menu li.menuparent &quot;). hover ( function() { $(this).addClass(&quot;over&quot;).find(&quot;> ul&quot;). show() ; }, function(){ $(this).removeClass(&quot;over&quot;).find(&quot;> ul&quot;).  hide() ; } ); });
What if we modify this? Make font bigger, fade in and out $(document).ready(function() { $(&quot;ul.nice-menu li.menuparent&quot;).hover( function() { $(this).addClass(&quot;over&quot;). css(&quot;font-size&quot;, &quot;16px&quot;) .find(&quot;> ul&quot;). show(‘slow’) ; }, function(){ $(this).removeClass(&quot;over&quot;). css(&quot;font-size&quot;, &quot;13px&quot;) .find(&quot;> ul&quot;).  hide(‘slow’) ; } });
Tool: Visual jQuery http://visualjquery.com/
Example 2: More or Less Modify Nice Menus to hide some elements
Example 2: More or Less Remember the Process: Step 1: Let Drupal know about our JavaScript In this case, theme (page.tpl.php) jQuery not loaded by default if no other scripts… So, need to make one change first…
Making Sure jQuery Gets Loaded In page.tpl.php, find this: <head> <title><?php print $head_title ?></title> <?php print $head ?> <?php print $styles ?> <?php print $scripts ?> … </head>
Making Sure jQuery Gets Loaded Replace with: <head> <title><?php print $head_title ?></title> <?php print $head ?> <?php print $styles ?> <?php drupal_add_js('misc/jquery.js', 'core', 'header'); print drupal_get_js(); ?> … </head> Or in Drupal 6, put an empty  script.js  file in your theme directory
Example 2: More or Less Step 2 of Process: Write the JavaScript Tip: Start from the outside and work inward  <script type=&quot;text/javascript&quot;> $(document).ready(function() { }); </script>
Example 2: More or Less Step 2.1 of Process: Select the component you want to modify. Tool: Firebug Firefox add-on Allows you to inspect page structure (among other things)
Example 2: More or Less Tip: Start from the outside and work inward We want to hide everything beyond the fifth menu item <script type=&quot;text/javascript&quot;> $(document).ready(function() { $('#nice-menu-2 li:nth-child(5) ~ li').hide(); }); </script>
Example 2: More or Less Tip: Start from the outside and work inward Now append “more” and “less” links <script type=&quot;text/javascript&quot;> $(document).ready(function() { $('#nice-menu-2 li:nth-child(5) ~ li').hide(); $('#nice-menu-2').append( '<li><?php print l('more', '', array('attributes' => array('class' => 'toggle'))); ?></li>' + '<li style=&quot;display:none&quot;><?php print l('less', '', array('attributes' => array('class' => 'toggle'))); ?></li>' ); }); </script>
Example 2: More or Less Finally, handle the “click” event <script type=&quot;text/javascript&quot;> $(document).ready(function() { $('#nice-menu-2 li:nth-child(5) ~ li').hide(); $('#nice-menu-2').append( '<li class=&quot;&quot;><?php print l('more', '', array('attributes' => array('class' => 'toggle'))); ?></li>' + '<li class=&quot;&quot; style=&quot;display:none&quot;><?php print l('less', '', array('attributes' => array('class' => 'toggle'))); ?></li>' ); $('.toggle').click(function() { $('#nice-menu-2 li:nth-child(5) ~ li').toggle(); return false;  //important! }); }); </script> Voila!
Example 3: Dynamic Form Components  Show character count as user is typing? No problem!
Example 3: Dynamic Form Components  Step 1: Let Drupal Know… Forms involved, so hook_form_alter (so module) jqintrochars.module: function jqintrochars_form_alter(&$form, $form_state, $form_id) { drupal_add_js(&quot;  //something goes here  &quot;, 'inline'); } We can use drupal_add_js() instead of drupal_set_html_head() because we’re inserting straight JavaScript code -- not any HTML…
Example 3: Dynamic Form Components  Step 2: Write the Code $(document).ready(function() { $('#edit-title'). after ( '<div id=\&quot;chars\&quot;>characters: 0</div>' ); });
Example 3: Dynamic Form Components  Step 2: Write the Code $(document).ready(function() { $('#edit-title'). after( '<div id=\&quot;chars\&quot;>characters: 0</div>' ). keyup(updateCount); }); function updateCount() { $('#chars'). html ( 'characters: ' + $(this).val().length ); } Ka-pow!
Could take additional action after some number of characters… function updateCount() { $('#chars').html( 'characters: ' + $(this).val().length ); if($(this).val().length > 20) { $('#edit-body').parent('.resizable-textarea').hide('slow'); } else { $('#edit-body').parent('.resizable-textarea').show('slow'); } }   Example 3: Dynamic Form Components  Sha-zam!
Example 4: Popup Calendars Remember to check if module already exists? CCK Date Module
Example 4: Popup Calendars But what if… You want to use the datepicker on other fields, not the Date CCK field? You’re on Drupal 5 and want to use jQuery UI datepicker? http://docs.jquery.com/UI/Datepicker
Tool: jQuery Update Module Brings Drupal up to date with jQuery 1.2.6 http://drupal.org/project/jquery_update
Example 4: Popup Calendars Create a new module Get the ui.datepicker.js and ui.datepicker.css files and put them in the module directory Here’s your hook_form_alter() code: function testdate_form_alter($form_id, &$form) { if($form_id == ‘presentation_node_form') { drupal_add_css (drupal_get_path('module', 'testdate') . '/ui.datepicker.css'); drupal_add_js (drupal_get_path('module', 'testdate') . '/ui.datepicker.js'); drupal_add_js (' $(document).ready(function() { $(&quot;#edit-title&quot;).datepicker({ closeAtTop: false }); }); ', 'inline'); } }
Example 4: Popup Calendars
Example 5: Multipart Forms An alternative to doing it in Drupal on the backend www.dublit.com
Example 5: Multipart Forms The game plan: Turn “Page” type into a two-part form “ Title” is on part 1 Body is hidden Next button “ Body” is on part 2 Title is hidden Submit button
Example 5: Multipart Forms Step 1: Let Drupal Know… Where’s the best place in this case? Module, hook_form_alter()  if($form_id == ' page_node_form ') {   drupal_add_js('   $(document).ready(function()  {   });   ', 'inline'); }
Example 5: Multipart Forms Find the first component, take action… Hide #edit-body-wrapper if($form_id == 'page_node_form') {   drupal_add_js('   $(document).ready(function()  {   $(“#edit-body-wrapper”).hide();   });   ', 'inline'); }
Example 5: Multipart Forms What’s the next thing you want to do? Change the button to say “Next” if($form_id == 'page_node_form') {   drupal_add_js('   $(document).ready(function()  {   $(“#edit-body-wrapper”).hide();   $(&quot;#edit-submit&quot;).val(&quot;Next&quot;).click(pageMng)   });   ', 'inline'); }
Example 5: Multipart Forms What should the pageMng function do when button is clicked? Change the button to say “Submit” Show title, hide body var page = 1; function pageMng() {   if(page == 1) {   $(this).val(&quot;Submit&quot;);   $(&quot;#edit-body-wrapper&quot;).show();   $(&quot;#edit-title-wrapper&quot;).hide();   page = 2;   return false;   } else {   return true;   } } Huzzah!
Thanks! Amit Asaravala www.returncontrol.com [email_address]

More Related Content

PPT
Php Basic Security
PPT
What's new in Rails 2?
PPTX
Wp meetup custom post types
ODP
HTML::FormHandler
PPT
jQuery Performance Rules
KEY
Geek Moot '09 -- Smarty 101
PPT
Writing Apps the Google-y Way
PDF
Making Sense of Twig
Php Basic Security
What's new in Rails 2?
Wp meetup custom post types
HTML::FormHandler
jQuery Performance Rules
Geek Moot '09 -- Smarty 101
Writing Apps the Google-y Way
Making Sense of Twig

What's hot (19)

PDF
Avinash Kundaliya: Javascript and WordPress
PDF
Make your own wp cli command in 10min
PPT
シックス・アパート・フレームワーク
PDF
Implement rich snippets in your webshop
PPT
PHP 5 Sucks. PHP 5 Rocks.
PPTX
LinkedIn Platform at LeWeb 2010
PDF
Curso Symfony - Clase 4
PDF
Curso Symfony - Clase 2
PPT
Система рендеринга в Magento
PPT
PDF
Laravel 로 배우는 서버사이드 #5
PPT
Mashups & APIs
PPT
Writing Apps the Google-y Way (Brisbane)
PDF
RubyBarCamp “Полезные gems и plugins”
PDF
Joomla Custom Fields - the next level
PPTX
Meetup django common_problems(1)
PDF
WordPress: From Antispambot to Zeroize
PDF
Simplifying Code: Monster to Elegant in 5 Steps
PPTX
Zero to SOLID
Avinash Kundaliya: Javascript and WordPress
Make your own wp cli command in 10min
シックス・アパート・フレームワーク
Implement rich snippets in your webshop
PHP 5 Sucks. PHP 5 Rocks.
LinkedIn Platform at LeWeb 2010
Curso Symfony - Clase 4
Curso Symfony - Clase 2
Система рендеринга в Magento
Laravel 로 배우는 서버사이드 #5
Mashups & APIs
Writing Apps the Google-y Way (Brisbane)
RubyBarCamp “Полезные gems и plugins”
Joomla Custom Fields - the next level
Meetup django common_problems(1)
WordPress: From Antispambot to Zeroize
Simplifying Code: Monster to Elegant in 5 Steps
Zero to SOLID
Ad

Viewers also liked (8)

PDF
Yahoo presentation: JavaScript Events
PPTX
Javascript
PPTX
Css margin and padding property
PPT
Jquery Example PPT
PDF
Cours php bac info
PPT
Jquery validate - TuanNA
PPTX
HTML5 & WAI-ARIA Forms with jQuery Validation
KEY
Search Analytics for Content Strategists
Yahoo presentation: JavaScript Events
Javascript
Css margin and padding property
Jquery Example PPT
Cours php bac info
Jquery validate - TuanNA
HTML5 & WAI-ARIA Forms with jQuery Validation
Search Analytics for Content Strategists
Ad

Similar to Smarter Interfaces with jQuery (and Drupal) (20)

PPT
Introduction To Lamp
PPT
WordPress as a Content Management System
PPT
Render API - Pavel Makhrinsky
PPT
Introduction to JQuery
PPT
jQuery Presentation - Refresh Events
PPT
Eugene Andruszczenko: jQuery
ODP
Drupal 7 Theming - what's new
PPT
Writing Pluggable Software
PPT
Boston Computing Review - Ruby on Rails
PPT
Dynamic Web Pages Ch 1 V1.0
PPT
Javascript
PPT
PDF
Building Web Interface On Rails
PPT
Framework
PPT
Building Complex GUI Apps The Right Way. With Ample SDK - SWDC2010
PPTX
Views notwithstanding
PPT
Web Scraping with PHP
PPT
Html and i_phone_mobile-2
PPT
course slides -- powerpoint
PPT
Vancouver League of Drupallers - Remembering the User (August 2008)
Introduction To Lamp
WordPress as a Content Management System
Render API - Pavel Makhrinsky
Introduction to JQuery
jQuery Presentation - Refresh Events
Eugene Andruszczenko: jQuery
Drupal 7 Theming - what's new
Writing Pluggable Software
Boston Computing Review - Ruby on Rails
Dynamic Web Pages Ch 1 V1.0
Javascript
Building Web Interface On Rails
Framework
Building Complex GUI Apps The Right Way. With Ample SDK - SWDC2010
Views notwithstanding
Web Scraping with PHP
Html and i_phone_mobile-2
course slides -- powerpoint
Vancouver League of Drupallers - Remembering the User (August 2008)

Recently uploaded (20)

PDF
Advanced Soft Computing BINUS July 2025.pdf
PDF
GamePlan Trading System Review: Professional Trader's Honest Take
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
CIFDAQ's Market Wrap: Ethereum Leads, Bitcoin Lags, Institutions Shift
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPT
Teaching material agriculture food technology
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Empathic Computing: Creating Shared Understanding
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPTX
Telecom Fraud Prevention Guide | Hyperlink InfoSystem
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
KodekX | Application Modernization Development
PPTX
Big Data Technologies - Introduction.pptx
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Advanced Soft Computing BINUS July 2025.pdf
GamePlan Trading System Review: Professional Trader's Honest Take
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
“AI and Expert System Decision Support & Business Intelligence Systems”
20250228 LYD VKU AI Blended-Learning.pptx
CIFDAQ's Market Wrap: Ethereum Leads, Bitcoin Lags, Institutions Shift
Spectral efficient network and resource selection model in 5G networks
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Diabetes mellitus diagnosis method based random forest with bat algorithm
Teaching material agriculture food technology
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Empathic Computing: Creating Shared Understanding
Review of recent advances in non-invasive hemoglobin estimation
Telecom Fraud Prevention Guide | Hyperlink InfoSystem
Advanced methodologies resolving dimensionality complications for autism neur...
KodekX | Application Modernization Development
Big Data Technologies - Introduction.pptx
Per capita expenditure prediction using model stacking based on satellite ima...
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows

Smarter Interfaces with jQuery (and Drupal)

  • 1. Creating Smarter Interfaces with jQuery Amit Asaravala www.returncontrol.com [email_address]
  • 2. What We’ll Cover Examples: Dynamic navigation More dynamic nav (or less?) Dynamic form components Popup calendars Multipart forms Learn: How jQuery works with Drupal Tips / techniques / tools
  • 3. Example 1: Dynamic Nav Expanding / Collapsing Nav Menus Nice Menus module
  • 4. Tip 1: Look for Existing Modules First LOTS o’ options for dynamic menus: Nice Menus Simple Menu Active Menus DHTML Menu Lucid Menu Quick Menu CC-Remix-NC http://www.flickr.com/photos/b-tal/163450213/
  • 5. Back to Example 1: Nice Menus Mostly CSS But uses jQuery to provide IE6 support
  • 6. Technique: The Process Let Drupal know about JavaScript / jQuery In a module Or in a theme (template / function) Write the JavaScript Find the component(s) you want to modify Determine what actions to apply
  • 7. 1. Let Drupal Know Nice Menus notifies Drupal in the module uses drupal_set_html_head() http://api.drupal.org/api/function/drupal_set_html_head Other option is drupal_add_js() http://api.drupal.org/api/function/drupal_add_js
  • 8. In nice_menus.module * function nice_menus_init() { drupal_set_html_head(' <!--[if IE]> <script type=&quot;text/javascript&quot; src=&quot;'. check_url(base_path() . 'misc/jquery.js') .'&quot;></script> <script type=&quot;text/javascript&quot; src=&quot;'. check_url(base_path() . 'misc/drupal.js') .'&quot;></script> <script type=&quot;text/javascript&quot; src=&quot;'. check_url(base_path() . drupal_get_path('module', 'nice_menus') .' /nice_menus.js ') .'&quot;></script> <![endif]--> '); … } * simplified
  • 9. 2. Write the JavaScript In nice_menus.js * * simplified $(document).ready(function() { $(&quot; ul.nice-menu li.menuparent &quot;). hover ( function() { $(this).addClass(&quot;over&quot;).find(&quot;> ul&quot;). show() ; }, function(){ $(this).removeClass(&quot;over&quot;).find(&quot;> ul&quot;). hide() ; } ); });
  • 10. What if we modify this? Make font bigger, fade in and out $(document).ready(function() { $(&quot;ul.nice-menu li.menuparent&quot;).hover( function() { $(this).addClass(&quot;over&quot;). css(&quot;font-size&quot;, &quot;16px&quot;) .find(&quot;> ul&quot;). show(‘slow’) ; }, function(){ $(this).removeClass(&quot;over&quot;). css(&quot;font-size&quot;, &quot;13px&quot;) .find(&quot;> ul&quot;). hide(‘slow’) ; } });
  • 11. Tool: Visual jQuery http://visualjquery.com/
  • 12. Example 2: More or Less Modify Nice Menus to hide some elements
  • 13. Example 2: More or Less Remember the Process: Step 1: Let Drupal know about our JavaScript In this case, theme (page.tpl.php) jQuery not loaded by default if no other scripts… So, need to make one change first…
  • 14. Making Sure jQuery Gets Loaded In page.tpl.php, find this: <head> <title><?php print $head_title ?></title> <?php print $head ?> <?php print $styles ?> <?php print $scripts ?> … </head>
  • 15. Making Sure jQuery Gets Loaded Replace with: <head> <title><?php print $head_title ?></title> <?php print $head ?> <?php print $styles ?> <?php drupal_add_js('misc/jquery.js', 'core', 'header'); print drupal_get_js(); ?> … </head> Or in Drupal 6, put an empty script.js file in your theme directory
  • 16. Example 2: More or Less Step 2 of Process: Write the JavaScript Tip: Start from the outside and work inward <script type=&quot;text/javascript&quot;> $(document).ready(function() { }); </script>
  • 17. Example 2: More or Less Step 2.1 of Process: Select the component you want to modify. Tool: Firebug Firefox add-on Allows you to inspect page structure (among other things)
  • 18. Example 2: More or Less Tip: Start from the outside and work inward We want to hide everything beyond the fifth menu item <script type=&quot;text/javascript&quot;> $(document).ready(function() { $('#nice-menu-2 li:nth-child(5) ~ li').hide(); }); </script>
  • 19. Example 2: More or Less Tip: Start from the outside and work inward Now append “more” and “less” links <script type=&quot;text/javascript&quot;> $(document).ready(function() { $('#nice-menu-2 li:nth-child(5) ~ li').hide(); $('#nice-menu-2').append( '<li><?php print l('more', '', array('attributes' => array('class' => 'toggle'))); ?></li>' + '<li style=&quot;display:none&quot;><?php print l('less', '', array('attributes' => array('class' => 'toggle'))); ?></li>' ); }); </script>
  • 20. Example 2: More or Less Finally, handle the “click” event <script type=&quot;text/javascript&quot;> $(document).ready(function() { $('#nice-menu-2 li:nth-child(5) ~ li').hide(); $('#nice-menu-2').append( '<li class=&quot;&quot;><?php print l('more', '', array('attributes' => array('class' => 'toggle'))); ?></li>' + '<li class=&quot;&quot; style=&quot;display:none&quot;><?php print l('less', '', array('attributes' => array('class' => 'toggle'))); ?></li>' ); $('.toggle').click(function() { $('#nice-menu-2 li:nth-child(5) ~ li').toggle(); return false; //important! }); }); </script> Voila!
  • 21. Example 3: Dynamic Form Components Show character count as user is typing? No problem!
  • 22. Example 3: Dynamic Form Components Step 1: Let Drupal Know… Forms involved, so hook_form_alter (so module) jqintrochars.module: function jqintrochars_form_alter(&$form, $form_state, $form_id) { drupal_add_js(&quot; //something goes here &quot;, 'inline'); } We can use drupal_add_js() instead of drupal_set_html_head() because we’re inserting straight JavaScript code -- not any HTML…
  • 23. Example 3: Dynamic Form Components Step 2: Write the Code $(document).ready(function() { $('#edit-title'). after ( '<div id=\&quot;chars\&quot;>characters: 0</div>' ); });
  • 24. Example 3: Dynamic Form Components Step 2: Write the Code $(document).ready(function() { $('#edit-title'). after( '<div id=\&quot;chars\&quot;>characters: 0</div>' ). keyup(updateCount); }); function updateCount() { $('#chars'). html ( 'characters: ' + $(this).val().length ); } Ka-pow!
  • 25. Could take additional action after some number of characters… function updateCount() { $('#chars').html( 'characters: ' + $(this).val().length ); if($(this).val().length > 20) { $('#edit-body').parent('.resizable-textarea').hide('slow'); } else { $('#edit-body').parent('.resizable-textarea').show('slow'); } } Example 3: Dynamic Form Components Sha-zam!
  • 26. Example 4: Popup Calendars Remember to check if module already exists? CCK Date Module
  • 27. Example 4: Popup Calendars But what if… You want to use the datepicker on other fields, not the Date CCK field? You’re on Drupal 5 and want to use jQuery UI datepicker? http://docs.jquery.com/UI/Datepicker
  • 28. Tool: jQuery Update Module Brings Drupal up to date with jQuery 1.2.6 http://drupal.org/project/jquery_update
  • 29. Example 4: Popup Calendars Create a new module Get the ui.datepicker.js and ui.datepicker.css files and put them in the module directory Here’s your hook_form_alter() code: function testdate_form_alter($form_id, &$form) { if($form_id == ‘presentation_node_form') { drupal_add_css (drupal_get_path('module', 'testdate') . '/ui.datepicker.css'); drupal_add_js (drupal_get_path('module', 'testdate') . '/ui.datepicker.js'); drupal_add_js (' $(document).ready(function() { $(&quot;#edit-title&quot;).datepicker({ closeAtTop: false }); }); ', 'inline'); } }
  • 30. Example 4: Popup Calendars
  • 31. Example 5: Multipart Forms An alternative to doing it in Drupal on the backend www.dublit.com
  • 32. Example 5: Multipart Forms The game plan: Turn “Page” type into a two-part form “ Title” is on part 1 Body is hidden Next button “ Body” is on part 2 Title is hidden Submit button
  • 33. Example 5: Multipart Forms Step 1: Let Drupal Know… Where’s the best place in this case? Module, hook_form_alter() if($form_id == ' page_node_form ') { drupal_add_js(' $(document).ready(function() { }); ', 'inline'); }
  • 34. Example 5: Multipart Forms Find the first component, take action… Hide #edit-body-wrapper if($form_id == 'page_node_form') { drupal_add_js(' $(document).ready(function() { $(“#edit-body-wrapper”).hide(); }); ', 'inline'); }
  • 35. Example 5: Multipart Forms What’s the next thing you want to do? Change the button to say “Next” if($form_id == 'page_node_form') { drupal_add_js(' $(document).ready(function() { $(“#edit-body-wrapper”).hide(); $(&quot;#edit-submit&quot;).val(&quot;Next&quot;).click(pageMng) }); ', 'inline'); }
  • 36. Example 5: Multipart Forms What should the pageMng function do when button is clicked? Change the button to say “Submit” Show title, hide body var page = 1; function pageMng() { if(page == 1) { $(this).val(&quot;Submit&quot;); $(&quot;#edit-body-wrapper&quot;).show(); $(&quot;#edit-title-wrapper&quot;).hide(); page = 2; return false; } else { return true; } } Huzzah!
  • 37. Thanks! Amit Asaravala www.returncontrol.com [email_address]