close ad
WARNING: Do Not Install the DREAMWEAVER CC 2017 or 2018 Update »
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

binding select list populated dynamically First Name Last Name

Thread began 2/02/2015 10:24 am by JBWebWorks | Last modified 2/03/2015 12:10 pm by Jason Byrnes | 1306 views | 9 replies |

JBWebWorks

binding select list populated dynamically First Name Last Name

I think this is treated as an array but not sure.

My select list
<option value="<?php echo $row_rs_members['First Name']?> <?php echo $row_rs_members['Last Name']?>" <?php if(in_array("['First Name']", $selected)) echo("selected=\"selected\""); ?>><?php echo $row_rs_members['First Name']?> <?php echo $row_rs_members['Last Name']?></option>

Not sure how to write the if statement?
<?php if(in_array("['First Name']",

Sign in to reply to this post

Jason ByrnesWebAssist

double check the name of the select list. if the name use [] at the end:
selectName[]

then it is an array
the if statement format would be:

if(in_array($row_rs_members['First Name'], $selected)

Sign in to reply to this post

JBWebWorks

Put this at top of page
<?php

if($_SERVER["REQUEST_METHOD"] == "POST") {

foreach($_POST as $key => $val) {

if(is_array($_POST[$key])) $_POST[$key] = implode(", ", $_POST[$key]);

}

}

?>

Put this before the form
<?php $selected = explode(", ", ValidatedField("index_500","player1")); ?>

and this is the form
<form id="form1" name="form1" method="post" action="">

<label for="player1"><strong>Your Name:</strong></label>
<select name="player1[]" id="player1">
<option value="" selected="selected">Select From Dropdown</option>
<?php
do {
?>
<option value="<?php echo $row_rs_members['First Name']?> <?php echo $row_rs_members['Last Name']?>" <?php if(in_array($row_rs_members['First Name'], $selected)) echo("selected=\"selected\""); ?>><?php echo $row_rs_members['First Name']?> <?php echo $row_rs_members['Last Name']?></option>
<?php
} while ($row_rs_members = mysql_fetch_assoc($rs_members));
$rows = mysql_num_rows($rs_members);
if($rows > 0) {
mysql_data_seek($rs_members, 0);
$row_rs_members = mysql_fetch_assoc($rs_members);
}
?>
</select>
<?php
if (ValidatedField('index_500','index_500')) {
if ((strpos((",".ValidatedField("index_500","index_500").","), "," . "1" . ",") !== false || "1" == "")) {
if (!(false)) {
?>
<span class="stylered">Name required</span>
<?php //WAFV_Conditional index.php index_500(1:)
}
}
}?>
<br />
<br />
<label for="tee1"><strong>Your Tee Choice:</strong></label>
<select name="tee1" id="tee1">
<option value="" selected="selected" <?php if (!(strcmp("", (ValidatedField("index_500","tee1"))))) {echo "selected=\"selected\"";} ?>>Select Your Tee</option>
<option value="Gold" <?php if (!(strcmp("Gold", (ValidatedField("index_500","tee1"))))) {echo "selected=\"selected\"";} ?>>Gold</option>
<option value="White" <?php if (!(strcmp("White", (ValidatedField("index_500","tee1"))))) {echo "selected=\"selected\"";} ?>>White</option>
<option value="Blue" <?php if (!(strcmp("Blue", (ValidatedField("index_500","tee1"))))) {echo "selected=\"selected\"";} ?>>Blue</option>
<option value="Black" <?php if (!(strcmp("Black", (ValidatedField("index_500","tee1"))))) {echo "selected=\"selected\"";} ?>>Black</option>
</select>
<?php
if (ValidatedField('index_500','index_500')) {
if ((strpos((",".ValidatedField("index_500","index_500").","), "," . "2" . ",") !== false || "2" == "")) {
if (!(false)) {
?>
<span class="stylered">Tee Required</span>
<?php //WAFV_Conditional index.php index_500(2:)
}
}
}?>
<br />
<br />
<label for="pairing1"><strong>Pairing Request:</strong></label>
<textarea name="pairing1" id="pairing1" cols="45" rows="5"><?php echo(ValidatedField("index_500","pairing1")) ?></textarea>
<br />
<br />
<input type="submit" name="submit2" id="submit2" value="Submit Saturday Signup" />
</p>
</form>

It seems that the if in array statement would have to include both First Name and Last Name, but not sure?

Currently the validation to require a choice for player1 works but does not bind the choice upon validation failed.

Sign in to reply to this post

Jason ByrnesWebAssist

ok, so if you need the first and last names, the format of the if statement would be:

if(in_array($row_rs_members['First Name']." ".$row_rs_members['Last Name'], $selected)

Sign in to reply to this post

JBWebWorks

Thanks Jason. I wasn't sure how to write the if statement. Works now.

One other question
I know that adding the progress bar to a form creates a bad jquery-blockui-formprocessing.js
Is there a way I can permanently correct that so that the jquery-blockui-formprocessing.js that is created is good?

Sign in to reply to this post

Jason ByrnesWebAssist

if you have the most recent version of Data bridge, there should not be a problem with the jquery-blockui-formprocessing.js

Sign in to reply to this post

JBWebWorks

I downloaded the newest version of Data Bridge
Installed it but i had not removed the extensions that i had installed that are incorporated in Data Bridge
So i went back and removed Data Bridge and the other extensions. I inadvertently removed validation toolkit. Yes, i kinda messed up.
Now i'm getting this error

Sign in to reply to this post

Jason ByrnesWebAssist

that error looks like the web assist installer did not run to complete the installation.

After installing the extension in the extension manager, open Dreamweaver, this should start the WebAssist installer. If the WebAssist installer does not start, you may need to open a PHP page to force it to launch.

after the WebAssist installer completes, make sure to restart Dreamweaver.

Sign in to reply to this post

JBWebWorks

The problem I caused is I installed Data Bridge1.21 without removing the individual extensions that are bundled with Data Bridge. Then realizing my problem I removed the extensions and by mistake removed Validation Toolkit 2.35.
Now i have removed the bundled products and reinstalled Data Bridge and Validation Toolkit which stopped the error I was having.
But when I apply validation to a form that i build, the validation is the old version, i.e.
<?php require_once("WA_ValidationToolkit/WAVT_Scripts_PHP.php"); ?>
<?php require_once("WA_ValidationToolkit/WAVT_ValidatedForm_PHP.php"); ?>

and not

<?php require_once("webassist/form_validations/wavt_validatedform_php.php"); ?>
<?php require_once("webassist/form_validations/wavt_scripts_php.php"); ?>
<?php require_once("webassist/form_validations/wavt_validatedform_php.php"); ?>

How do i fix this?

Got it working now by uninstalling Validation Tool Kit and reinstalling Data Bridge.

There are still some code bugs in the validation show if, but I can work around that.

Sign in to reply to this post

Jason ByrnesWebAssist

Validation toolkit is a part of Data Bridge, so it should not be installed along side Data Bridge.

Sign in to reply to this post
loading

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...