close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Form Issue

Thread began 8/12/2022 5:52 am by yogastudents362523 | Last modified 8/13/2022 8:51 am by Ray Borduin | 135 views | 4 replies |

yogastudents362523

Form Issue

Hello,

I apologise, but I do not know Javascript, and so am uncertain how to incorporate the underneath into a form.

I have a lot of Presenters from all around the world, and need them to indicate to me what timezone they reside in.

I found a little bit of javascript code that neatly creates an array of timezones. This can then create an input box in the obvious way. My presenters can then select the one applicable to them.

However, I am uncertain how to send the value they have selected across to the update query, when they push the "Update" button.

I am sure that, as ever, it is quite elementary.
Thank you for your kindness.

Here is the coding I have thus far

<form name="mytimezoner" method="post" action="">

<?php
$regions = array(
'America' => DateTimeZone::AMERICA,
'Pacific' => DateTimeZone::PACIFIC,
'Europe' => DateTimeZone::EUROPE,
'Australia' => DateTimeZone::AUSTRALIA,
'Asia' => DateTimeZone::ASIA,
'Indian' => DateTimeZone::INDIAN,
'Africa' => DateTimeZone::AFRICA,
'Atlantic' => DateTimeZone::ATLANTIC,
'Antarctica' => DateTimeZone::ANTARCTICA
);

$timezones = array();
foreach ($regions as $name => $mask)
{
$zones = DateTimeZone::listIdentifiers($mask);
foreach($zones as $timezone)
{
// Get current time
$time = new DateTime(NULL, new DateTimeZone($timezone));

// Change from military time
$ampm = $time->format('H') > 12 ? ' ('. $time->format('g:i a'). ')' : '';

// Remove region name and add a sample time
$timezones[$name][$timezone] = substr($timezone, strlen($name) + 1) . ' - ' . $time->format('H:i') . $ampm;
}
}


// Create Viewable Selections


print '<label>Select Your Timezone</label><select name = "timezone" id="timezone">';
foreach($timezones as $region => $list)
{
print '<optgroup label="' . $region . '">' . "\n";
foreach($list as $timezone => $name)
{
// print '<option name="' . $timezone . '">' . $name . '</option>' . "\n";
print '<option value="' . $timezone . '">' . $name . '</option>' . "\n";
}
print '<optgroup>' . "\n";
}
print '</select>';
?>

<input type="submit" name="Update" class="button fit primary" value="Press to Save and Update">
</form>

I am simply uncertain what to put in the fields DataAssist kindly provides for me as a part of its convenient Update query.

Thank you.

Sign in to reply to this post

yogastudents362523

RESOLVED

I just needed a few hours break.

I do, however, have the remaining issue that I know how to ensure that an form option menu displays whatever is the current value through a piece of coding such as:

<option value="A" <?php if(($rsQuery->getColumnVal("Whatever")) == "A") echo ("selected");?>>Value A</option>

However, when "Update" has been pushed, the option menu does not immediately update itself. It is instead necessary to manually re-upload the page.

I find this clunky, and would prefer something more dynamic. I have read on Google that a piece of Ajax or Javascript code will do this, but have yet to find an example. If you know how to do this, I would be obliged, thank you

Sign in to reply to this post

Ray BorduinWebAssist

I'm not exactly sure what you are referring to. When the update button is pressed the form should submit and be refreshed. Maybe if you gave me a url to see what is happening I could understand what is going wrong compared to what you expect to happen.

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

yogastudents362523

Hi,

I have given a URL in the private area.

When you are there, it will be possible to select a different timezone, which is then immediately registered in the database.
However, like all other pages I have that use similar <select><option> form inputs, when I have the select dynamic so I read the values in the datagbase and apply them to "selected" to produce the html of:

<option value="Africa/Accra" selected>Accra </option>

then when I use the form to select and produce some other selection, the new selections never appear instantly and dynamically. I always have to refresh the page before the relevant new option sticks, as the default.

Sign in to reply to this post

Ray BorduinWebAssist

This is just an issue with order of operations. Since the update code is after the recordset code, the update doesn't take place until after the recordset data is populated, so it isn't reflected on the page until the page refreshes.

The easiest solution is to add a redirect to the update server behavior to refresh the page. Set the redirect to the current page name and then the page will be refreshed and the recordsets repopulated.

The other solution is to use the session instead of the recordset in the update server behavior to set the ID to be updated. Then you can move the update code above the recordset code and the page wouldn't need to refresh since the update takes place first.

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

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