Image drag and drop module using AJAX

Venuram - January 3, 2009 - 06:45

Hi,

I am new to drupal.Currently we got a project in drupal.The module is Image drag and drop using jquery. I need a help to complete this and i can`t find any module for drag and drop in drupal.org.

Please see below for the details..

**************************************************************************************************

Ajax task:

(Please See the attached image)

There is a picture of a chain. There are also 3 Items. Each item has a price.

The task is to build a drag-and-drop ajax interface that will allow for items to be drags onto the up/down pointing arrows on the chain.

Each time an item is dropped on an arrow it stays on the chain and the total value is calculated.

* Use of the Jquery library is highly recommended as it has various useful libraries such as the Drag and Drop Jquery library.

**************************************************************************************************

I will be very thankfull to you if i got solution or any module for this..

Thanks,
Venu

about jquery

ashiwebi - January 3, 2009 - 07:33

Give your mail id I will send you one pdf file for jquery and drupal.I hope it will help you out.

My mail id

Venuram - January 5, 2009 - 04:18

Hi ashiwebi,

Thanks for your reply. This is my email id venugopals@rajasri.net.

about jquery

ashiwebi - January 5, 2009 - 05:54

The file size is big about 10 MB.I donot think it can transferred through mail.

Thank you very much

Venuram - January 5, 2009 - 06:06

Hi ashish,

Thanks for sending a mail. I will read it and let you know.. I have invited you in google talk. Please accept my invitation..

Thanks..

Multi step registration form - assisance needed

Venuram - January 5, 2009 - 06:09

Hi ashish,

I need assistance in multi-step registration form..

The multi-step registration form consists of

Step 1: Email address and password

Step 2: First and Last name

Step 3: Display all the information from previous fields and submit form.

I have completed step1, step2 and getting the form values in step3, now i have to show the form values in step3.

To view the form values in step3 which type i want to use.I am getting the values but i dont know how to display in this formt.

Email : xxxx@yyy.com

password : xxxxxxx

First Name : xxxxxx

Last Name : xxxxxx

Can you please give an idea..

Thanks in advance..

registration form

ashiwebi - January 5, 2009 - 08:31

Check the profile module in which you can add more fields at the time of registration process.You can also check the webform module.

Let me know where are you from?

How you create the step1 and step2?

Wish you all the best

Code for multi-step registration form

Venuram - January 5, 2009 - 09:03

Hi,

Please see the code for multi-step registration form.

<?php
function my_module_menu() {
$items['my_module/form'] = array(
'title' => t('My form'),
'page callback' => 'my_module_form',
'access arguments' => array('access content'),
'description' => t('My form'),
'type' => MENU_CALLBACK,
);
return $items;
}

function my_module_form() {
return drupal_get_form('my_module_my_form');
}

function my_module_my_form($form_state) {

if (empty($form_state['storage']['step'])) {
// we are coming in without a step, so default to step 1
$form_state['storage']['step'] = 1;
}

//demo different fields on different steps
switch ($form_state['storage']['step']) {
case 1:
if($form_state['storage']['page_one_values']['email']=="")
{
$form['name']['email'] = array(
'#type' => 'textfield',
'#title' => t('Email Address'),
'#default_value' => $form_state['values']['email'], // changed
'#description' => "Please enter your email address.",
);
}
else
{
$form['name']['email'] = array(
'#type' => 'textfield',
'#title' => t('Email Address'),
'#default_value' => $form_state['storage']['page_one_values']['email'], // changed
'#description' => "Please enter your email address.",
);
}

if($form_state['storage']['page_one_values']['password']=="")
{
$form['name']['password'] = array(
'#type' => 'password',
'#title' => t('Password'),
'#default_value' => $form_state['values']['password'], // added
);
}
else
{
$form['name']['password'] = array(
'#type' => 'textfield',
'#title' => t('Password'),
'#default_value' => $form_state['storage']['page_one_values']['password'], // added
);
}
break;
case 2:

if($form_state['storage']['values'][$form_state['storage']['step']]['first']=="")
{
$form['name']['first'] = array(
'#type' => 'textfield',
'#title' => t('First name'),
'#default_value' => $form_state['values']['first'], // changed
'#description' => "Please enter your first name.",
'#maxlength' => 20,
);
}
else
{
$form['name']['first'] = array(
'#type' => 'textfield',
'#title' => t('First name'),
'#default_value' => $form_state['storage']['values'][$form_state['storage']['step']]['first'], // added
'#description' => "Please enter your first name.",
'#maxlength' => 20,
);
}

if($form_state['storage']['values'][$form_state['storage']['step']]['last']=="")
{
$form['name']['last'] = array(
'#type' => 'textfield',
'#title' => t('Last name'),
'#default_value' => $form_state['values']['last'], // added
);
}
else
{
$form['name']['last'] = array(
'#type' => 'textfield',
'#title' => t('Last name'),
'#default_value' => $form_state['storage']['values'][$form_state['storage']['step']]['last'], // added
);
}
break;

default:

$form_state['storage']['values'][$form_state['storage']['step']] = $form_state['values'];

$form['name']['email'] = array(
'#type' => 'textfield',
'#title' => t('Email Address'),
'#default_value' => $form_state['storage']['page_one_values']['email'], // changed
);

$form['name']['password'] = array(
'#type' => 'textfield',
'#title' => t('Password'),
'#default_value' => $form_state['storage']['page_one_values']['password'], // added
);

$form['name']['first'] = array(
'#type' => 'textfield',
'#title' => t('First name'),
'#default_value' => $form_state['storage']['values'][$form_state['storage']['step']]['first'], // added
);

$form['name']['last'] = array(
'#type' => 'textfield',
'#title' => t('Last name'),
'#default_value' => $form_state['storage']['values'][$form_state['storage']['step']]['last'], // added
);

break;
}

//don't show back button on first tab
if ($form_state['storage']['step'] > 1) {
$form['previous'] = array(
'#type' => 'submit',
'#value' => '<< Previous'
);
}
if ($form_state['storage']['step'] > 2) {

$form['submit'] = array(
'#type' => 'submit',
'#value' => 'Submit'
);
}
//show next button all the time in this demo
if (!($form_state['storage']['step'] > 2))
{
$form['next'] = array(
'#type' => 'submit',
'#value' => 'Next >>'
);
}
return $form;

}

// We modify this function so it can validate page 2
function my_module_my_form_validate($form, &$form_state)
{
// Validate page 2 here
if ($form_state['clicked_button']['#id']=='edit-next')
{
if ($form_state['storage']['step'] == 2)
{
$first_name = $form_state['values']['first'];
$last_name = $form_state['values']['last'];
if (!$first_name)
{
form_set_error('first', 'Please enter your first name.');
}
if (!$last_name)
{
form_set_error('last', 'Please enter your last name.');
}
return;
}

elseif ($form_state['storage']['step'] == 1)
{
$email_name = $form_state['values']['email'];
$password_name = $form_state['values']['password'];

if (!$email_name)
{
form_set_error('email', 'Please enter your email address.');
}
elseif (!valid_email_address($email_name))
{
form_set_error('submitted][email_address', t('The email address appears to be
invalid.'));
}

if (!$password_name)
{
form_set_error('password', 'Please enter your password.');
}
}
}
}

function my_module_my_form_submit($form, &$form_state)
{

// check the button that was clicked and action the step chagne
if ($form_state['clicked_button']['#id']=='edit-previous')
{
$form_state['storage']['step']--;
}
elseif ($form_state['clicked_button']['#id']=='edit-next')
{
$form_state['storage']['step']++;
}

//tell Drupal we are redrawing the same form
$form_state['rebuild'] = TRUE;

if($form_state['storage']['step'] == 2)
{
$form_state['storage']['page_one_values'] = $form_state['values'];
}
else
{
$form_state['storage']['values'][$form_state['storage']['step']] = $form_state['values'];

$Email = $form_state['storage']['page_one_values']['email'];
$Pass = $form_state['storage']['page_one_values']['password'];
$FirstName = $form_state['storage']['values'][$form_state['storage']['step']]['first'];
$LastName = $form_state['storage']['values'][$form_state['storage']['step']]['last'];

if ($form_state['clicked_button']['#id']=='edit-submit')
{
mysql_query("INSERT INTO my_module(email, password, FirstName, LastName) VALUES ('$Email', '$Pass',
'$FirstName','$LastName')") or die(mysql_error());
drupal_set_message('Your form has been submitted');
unset ($form_state['storage']); // This value must be unset or we will
// not be redirected! This is because
// $form_state['rebuild'] gets set to TRUE
// when 'storage' is set. See code sample

//$form_state['redirect'] = 'node'; // Here's how we redirect the user.
}
}

}

In the above code i am printing the form values in default case, here i can display in textfield only but i need to display in this format:

Email : xxxx@yyy.com

password : xxxxxxx

First Name : xxxxxx

Last Name : xxxxxx

Please suggest an idea. Is it possible please come online.

Thanks,
Venu

There is a plugin for

kovalev - January 5, 2009 - 17:06

There is a plugin for jQuery, for enabling of drag&drop/resize/select... You can find it here:
http://ui.jquery.com/
http://docs.jquery.com/UI

------------------------------------------------------------------------------------------------------------------------------------
Sergata - פיתוח תוכנה

 
 

Drupal is a registered trademark of Dries Buytaert.