Forums

how to make a simple dialog box

daffy 25 Jun, 2010
I often need a simple yes/no dialog or a cancel/continue dialog.
I know I can do this with chronoforms with two radio buttons and a submit but this involves the client taking two actions.

what I want is two buttons A which does functionA and redirects to location A
and button B which does functionB and redirects to location B.

I have tried and see that I can have two submit buttons on a chronoform but I don't see how to redirect differently and is using chronoforms here rather like using a steam-hammer to crack a nut?
--
Dave
GreyHead 26 Jun, 2010
Hi Dave,

If it's a simple redirect them you can create a button wrapped in a link.
<a href='index.php'><input type='button' value='Go home'/></a>
You can add a JavaScript action to that if needed.

If you want the button to trigger some PHP then you can create a little ChronoForm with two submit buttons each with a different name or value. Then check the value in the OnSubmit Before box.

Bob
daffy 26 Jun, 2010
Thanks again Bob,
That is what I needed pushing towards

If you want the button to trigger some PHP then you can create a little ChronoForm with two submit buttons each with a different name or value. Then check the value in the OnSubmit Before box.



But I don't yet see how this gives me two redirection paths I shall have to experiment.

In the procedural programming world where I come from, flexible dialog boxes are very common. Supply a message and put what buttons you want..perhaps 'Yes', 'No', 'Cancel' and supply an action for each button. Yes = do something No = do something else cancel = go back to where you came from. It would be nice if chronoforms offered such a simple flexible dialog box that required no javascript or PHP to set up.

Beware of wrapping a button in a link. I did that as part of a process of putting a record in the database and it took me a long time to work out why I kept getting two records in the database instead of one. Clicking the button caused a double action !
--
dave
daffy 26 Jun, 2010
Well I am trying here is my HTML chronoform code
<div class="form_item">
  <div class="form_element cf_text"> <span class="cf_text">Do you really want to change the person setting?</span> </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_button">
    <input value="yes" name="button_1" type="submit" />
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_button">
    <input value="no" name="button_2" type="submit" />
  </div>
  <div class="cfclear"> </div>
</div>


I do not see how I can put a link around these buttons because they are special chronoform buttons.

Then in the on before sending email (I don't have emails set up of course) I put something like:
echo "<h1>hello</h1>";
$result = JRequest(????);
if ($result == ???)
{


};


I get nothing for my shout of hello because I don't have redirect or any action set up ?
Your examples given do not show any dependency on the data of the form. How would I get the submitted values of the buttons at this point?
Thanks for any help.
--
Dave
This topic is locked and no more replies can be posted.