close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Spry Tabbed Panels in DreamWeaver CS4 Dilemma

Thread began 3/22/2009 4:08 pm by jojotoronald374823 | Last modified 3/25/2009 7:51 pm by Danilo Celic | 9271 views | 4 replies |

jojotoronald374823

Spry Tabbed Panels in DreamWeaver CS4 Dilemma

In a nut shell: I've placed a php form to be processed through email on the fifth tab of a 5 panel spry tab in Dreamweaver CS4. When I click the submit button to send the form (and the form is not completely filled out--deliberately--I just want to test "sticky fields" to see if it's working correctly, the web page goes back to the default tab, which is exactly what I don't want. I want it to stay on the 5 tab. What's the solution? Much thanks, Ronald.

Sign in to reply to this post

Ray BorduinWebAssist

One solution is probably to add a url parameter and javascript or php code written by hand to ensure that the correct tab stays selected. I'm not that familiar with spry tabbed panels so I'm not sure the precise code.

Sign in to reply to this post
Did this help? Tips are appreciated...

Danilo Celic

You can determine which panel to display by using the defaultTab option passed into the constructor for the panel. Take a look at the code on the Spry Tabbed Panels sample page, in particular the first example. You'll see this as the constructor:

var tp1 = new Spry.Widget.TabbedPanels("tp1", { defaultTab: 2 });

The first tab is tab 0 (zero), so setting defaultTab to 2 causes tab 3 to be shown by default. So for your example, you'd need to set the default tab to 4 (fifth tab) to make your form page display. In PHP it could be as simple as:
var tp1 = new Spry.Widget.TabbedPanels("tp1", { defaultTab: <?php echo($tabToShow); ?> });

You'd have a default value for $tabToShow set to 0 (zero) and if the form submit doesn't pass validation, then you'd set $tabToShow to 4.

Sign in to reply to this post

jojotoronald374823

Attention: danilo Re: Spry Tabbed Panel Dilemma

Okay. I understand conceptually what you are saying. At this point in time I haven't built up enough technical expertise in PHP, though I am begging to learn. (Would you recommend a good book for me).

The form processing code is as follows:<?php
if (array_key_exists('send', $_POST)) {
//mail processing script
// remove escape characters from POST array
if (PHP_VERSION < 6 && get_magic_quotes_gpc()) {
function stripslashes_deep($value) {
$value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value);
return $value;
}
$_POST = array_map('stripslashes_deep', $_POST);
}

$to = 'jojotoronald@aol.com'; //use your own email address
$subject = 'Contact information for quote on job';

// list expected fields
$expected = array('name', 'business', 'addressStreet', 'city', 'state', 'zip', 'phone', 'email', 'inquire');
// set required fields
$required = array('name', 'business', 'addressStreet', 'city', 'state', 'zip', 'phone', 'email', 'inquire');
// create empty array for any missing fields
$missing = array();

// assume that there is nothing suspect
$suspect = false;

// create a pattern to locate suspect phrases
$pattern = '/Content-Type:|Bcc:|Cc:/i';

// function to check for suspect phrases
function isSuspect($val, $pattern, &$suspect) {
// if the variable is an array, loop through each element
// and pass it recursively back to the same function
if (is_array($val)) {
foreach ($val as $item) {
isSuspect($item, $pattern, $suspect);
}
}
else {
// if one of the suspect phrases is found, set Boolean to true
if (preg_match($pattern, $val)) {
$suspect = true;
}
}
}
// check the $_POST array and any subarrays for suspect content
isSuspect($_POST, $pattern, $suspect);
if ($suspect) {
$mailSent = false;
unset($missing);
} else {

// process the $_POST variables
foreach ($_POST as $key => $value) {
// assign to temporary variable and strip whitespace if not an array
$temp = is_array($value) ? $value : trim($value);
// if empty and required, add to $missing array
if (empty($temp) && in_array($key, $required)) {
array_push($missing, $key);
} elseif (in_array($key, $expected)) {
// otherwise, assign to a variable of the same name as $key
${$key} = $temp;
}
}
}
// go ahead only if not suspect and all required fields OK
if (!suspect && empty($missing)) {
//build the message
$message = "Name: $name\r\n\r\n";
$message .= "Firm's name: $business\r\n\r\n";
$message .= "Street address: $addressStreet\r\n\r\n";
$message .= "City: $city\r\n\r\n";
$message .= "State: $state\r\n\r\n";
$message .= "Zip code: $zip\r\n\r\n";
$message .= "Phone number: $phone\r\n\r\n";
$message .= "Email address: $email\r\n\r\n";
$message .= "Nature of inquiry: $inquire";

// limit line lenght to 70 characters
$message = wordwrap($message, 70);



// send it

$mailSent = mail($to, $subject, $message);
if ($mailSent) {
// $missing is no longer needed if the email is sent, so unset it
unset($missing);
}
}
}

Where and how do I set the code for $tabToShow and what would that code be. Much thanks in advance. Ronald

Sign in to reply to this post

Danilo Celic

Originally Said By: jojotoronald374823
  Okay. I understand conceptually what you are saying. At this point in time I haven't built up enough technical expertise in PHP, though I am begging to learn. (Would you recommend a good book for me).  



Sorry, no recommendations on a PHP book, as I've never really read any, I've pulled everything by knowing what I wanted to do and used Google to find out how. For Dreamweaver users I have seen David Powers books recommended quite a bit.

First I would set $tabToShow = 0; at the top of you page, above the "if (array_key_exists('send', $_POST)) {" that starts off the code block you pasted. This will allw $tabToshow to have a default value when the page is first loaded (no form post), or when the form has posted and the form validation has passed.

I would add an else statement to the "if (!suspect && empty($missing)) {" if statement. See below. Hopefully it comes through to the forum as your code block didn't go into the forum well.

// go ahead only if not suspect and all required fields OK
if (!suspect && empty($missing)) {
//build the message
$message = "Name: $name\r\n\r\n";
$message .= "Firm's name: $business\r\n\r\n";
$message .= "Street address: $addressStreet\r\n\r\n";
$message .= "City: $city\r\n\r\n";
$message .= "State: $state\r\n\r\n";
$message .= "Zip code: $zip\r\n\r\n";
$message .= "Phone number: $phone\r\n\r\n";
$message .= "Email address: $email\r\n\r\n";
$message .= "Nature of inquiry: $inquire";

// limit line lenght to 70 characters
$message = wordwrap($message, 70);



// send it

$mailSent = mail($to, $subject, $message);
if ($mailSent) {
// $missing is no longer needed if the email is sent, so unset it
unset($missing);
}
}
else{ // suspect or at least one required field missing
$tabToshow = 4; // 4 = 5th tab
}
}
Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...