Forums

Creating a Recursive Data Entry Page

sklakken 02 Mar, 2009
I’m creating a Second Life registration form. In my first step, I’d simply like perform the following steps recursively so a user can determine if a requested name is available:

1. Enter the First Name and select the Last Name (drop down list).
2. Submit the “Is Available” Request.
3. Check to determine if the Second Life name is available.
4. Repopulate the original form with the submitted data.
5. Display an “Available/Not Available” message.

The basic idea is that the same form is repopulated and checks are made any number of times before a user moves onto the actual registration.

I’ve successfully used the SL API using the “onSubmit” (after) code. But I didn’t see where CronoEngine allows me to revert back to the original page for a refresh, if desired. I also tried the “redirectURL” method, but that didn’t work either (possibly a learning curve issue).

I’m sure there’s a simple answer to this “newbee” problem. Your help is greatly appreciated!
GreyHead 02 Mar, 2009
Hi slakken,

The easy way to do this is to use the server-side validation box on the Validation tab. There's a sample code snippet by the box.

Bob
sklakken 02 Mar, 2009
That's a great feature Bob, Thanks! What happens now, however, is that I'm back to presenting an empty page when the validation passes. What I'd rather do is present the same screen again with a "Second Life Name Available" message and present a link for the Registration Page.

Please advise...

Thanks,
Scott
GreyHead 02 Mar, 2009
Hi sklakken,

If you put any php+html in the OnSubmit oxes that will display on the 'blank screen'.

Or you can reshow the form with showform() - if you use showform($post) then ChronoForms will re-display the input values as well.

Or you can use the ReDirect url to go to any page on your site.

Bob
sklakken 02 Mar, 2009
Thanks, Bob. For clarity's sake, where would you place the showform() or showform($post) call?
GreyHead 02 Mar, 2009
Hi sklakken,

Needs to be the last processing statement. If you are using the Autogenerated code then it has to go in the OnSubmit After box - and you have to use Run Order to set that after the Autogenerated Code.

If you aren't saving to the database - or you want to prevent that then either of the OnSubmit boxes but follow it with $error_found = true; which will suppress the sending of emails and any other processing.

Bob
sklakken 03 Mar, 2009
Bob, thank you very much for your help! I was able to accomplish my task by using the showform($post) method within the OnSubmit code section.


<?php

showform($post);

?>


The only problem I had is that the form did not reshow the form fields. This is because there were no “value” statements generated in the input tags. I checked the Auto Generated Code form fields and everything was listed as expected. In any event, I got around this by using PHP code and setting values from the previous post.


<?php

  require_once('llsd.php');

...

  $firstName  = $_POST['text_1'];
  $idLastName = $_POST['select_2'];

...

<!-- First Name -->

<div class="form_item">
  <div class="form_element cf_textbox">
    <label class="cf_label">First Name</label>

    <input class="cf_inputbox required" 
                 maxlength="150" size="30" 
                 id="text_1" name="text_1" 
                 type="text" value="<?php echo $firstName ?>" />

    <a class="tooltiplink" onclick="return false;">
      <img height="16" border="0" 
           width="16" class="tooltipimg"              
           src="components/com_chronocontact/css/images/tooltip.png"/>
    </a>
    <div class="tooltipdiv">First Name :: Select your first name</div>
  </div>
  <div class="clear"> </div>
</div>

<!-- Last Name -->

<div class="form_item">
  <div class="form_element cf_dropdown">
    <label class="cf_label">Last Name</label>

    <select name="select_2" id="select_2" >
      <?php
        $last_names = llsd_get(URI_GET_LAST_NAMES);

        foreach ($last_names as $last_name_id => $name)
        {
          print '<option ';

          if ($idLastName == $last_name_id)
          {
            print 'selected ';
          }
          print 'value="'.$last_name_id.'">'.$name.'</option>';
        }
      ?>
    </select>
...


My next challenge is to pass the accepted Second Life name into the next form. If you could please suggest an approach, that’d be great!

As an FYI, I think your forum support is outstanding; and our company will purchase a license in the near future!

- Scott
Max_admin 03 Mar, 2009
Hi Scott,

is the name posted using some field ? you can get it with PHP:

<?php echo JRequest::getVar('fieldname'); ?>


Cheers
Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
sklakken 03 Mar, 2009
That was the only clue I needed. Thank you Bob and Max for your help. The remainder of my project should be simply academic. 🙂

- Scott
This topic is locked and no more replies can be posted.