Forums

Combine multiple inputs into a hidden field?

yaksushi 26 Aug, 2010
I have a form that I would like to use so users can input markers into phoca maps. I need to combine the radio button inputs and the drop down inputs into one database entry called description. I want the user to be able to select from the options to fill out the description field in phoca maps markers like this:

Size:
Target Fish:
Parking:
Launch Fees:
Kayak Cart Needed:
Camping Available:
Difficulty:

Any help would be greatly appreciated!


<div class="form_item">
  <div class="form_element cf_heading">
    <h1 class="cf_text">Fishing Location Form</h1>
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_textbox">
    <label class="cf_label" style="width: 150px;">Location Name:</label>
    <input class="cf_inputbox" maxlength="150" size="30" title="" id="text_4" name="title" type="text" />
  
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_textbox">
    <label class="cf_label" style="width: 150px;">latitude :</label>
    <input class="cf_inputbox required" maxlength="150" size="30" title="" id="text_1" name="latitude" type="text" />
  
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_textbox">
    <label class="cf_label" style="width: 150px;">longitude :</label>
    <input class="cf_inputbox required" maxlength="150" size="30" title="" id="text_2" name="longitude" type="text" />
  
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_heading">
    <h3 class="cf_text">Site Attributes</h3>
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_textbox">
    <label class="cf_label" style="width: 150px;">Acres:</label>
    <input class="cf_inputbox validate-number" maxlength="150" size="30" title="" id="text_14" name="text_14" type="text" />
  
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_checkbox">
    <label class="cf_label" style="width: 150px;">Target Fish:</label>
    <div class="float_left">
      <input value="Bass" title="" class="radio validate-one-required" id="check00" name="check0[]" type="checkbox" />
      <label for="check00" class="check_label">Bass</label>
      <br />
      
<input value="Catfish" title="" class="radio validate-one-required" id="check01" name="check0[]" type="checkbox" />
      <label for="check01" class="check_label">Catfish</label>
      <br />
      
<input value="Gar" title="" class="radio validate-one-required" id="check02" name="check0[]" type="checkbox" />
      <label for="check02" class="check_label">Gar</label>
      <br />
      
<input value="Drum" title="" class="radio validate-one-required" id="check03" name="check0[]" type="checkbox" />
      <label for="check03" class="check_label">Drum</label>
      <br />
      
<input value="Trout" title="" class="radio validate-one-required" id="check04" name="check0[]" type="checkbox" />
      <label for="check04" class="check_label">Trout</label>
      <br />
      

    </div>
    
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_dropdown">
    <label class="cf_label" style="width: 150px;">Parking:</label>
    <select class="cf_inputbox validate-selection" id="select_16" size="1" title=""  name="select_16">
    <option value="">Choose Option</option>
      <option value="Yes">Yes</option>
<option value="No">No</option>

    </select>
    
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_dropdown">
    <label class="cf_label" style="width: 150px;">Launch/Ramp Fees:</label>
    <select class="cf_inputbox validate-selection" id="select_17" size="1" title=""  name="select_17">
    <option value="">Choose Option</option>
      <option value="Yes">Yes</option>
<option value="No">No</option>

    </select>
    
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_dropdown">
    <label class="cf_label" style="width: 150px;">Kayak cart needed:</label>
    <select class="cf_inputbox validate-selection" id="select_18" size="1" title=""  name="select_18">
    <option value="">Choose Option</option>
      <option value="Yes">Yes</option>
<option value="No">No</option>

    </select>
    
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_dropdown">
    <label class="cf_label" style="width: 150px;">Camping Available:</label>
    <select class="cf_inputbox validate-selection" id="select_19" size="1" title=""  name="select_19">
    <option value="">Choose Option</option>
      <option value="Yes">Yes</option>
<option value="No">No</option>

    </select>
    
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_dropdown">
    <label class="cf_label" style="width: 150px;">Difficulty:</label>
    <select class="cf_inputbox validate-selection" id="select_20" size="1" title=""  name="select_20">
    <option value="">Choose Option</option>
      <option value="Easy">Easy</option>
<option value="Moderate">Moderate</option>
<option value="Hard">Hard</option>

    </select>
    
  </div>
  <div class="cfclear"> </div>
</div>

<input value="1" id="hidden_5" name="displaygps" type="hidden" />

<input value="0" id="hidden_7" name="icon" type="hidden" />

<input value="0" id="hidden_6" name="markerwindow" type="hidden" />

<input value="0" id="hidden_9" name="published" type="hidden" />

<input value="1" id="hidden_8" name="catid" type="hidden" />

<div class="form_item">
  <div class="form_element cf_button">
    <input value="Submit" name="button_3" type="submit" />
  </div>
  <div class="cfclear"> </div>
</div>
GreyHead 26 Aug, 2010
Hi yaksushi,

I didn't know that Jan had done a maps component, I must take a look.

You can create a new variabel in the OnSubmit Before box (NB this only runs if Send Emails is set to yes on the Form General tab).
<?php
$size =& JFactory::getInt('text_14', '', 'post');
$fish =& JRequest::getVar('check0', '', 'post');
. . .
$marker = $size."\n".$fish."\n". . . .;
JRequest::setVar('marker', $marker);
?>
Note: very rough code and needs careful completion & debugging!

Bob
yaksushi 26 Aug, 2010
Thanks for your very fast reply, I'm a little confused on a few things.

1:
$fish =& JRequest::getVar('check0', '', 'post');


should it be ?
'check00', 'check01', 'check02', 'post');


2: how do I handle the drop down yes or no boxes?

3: where is the OnSubmit Before box?

Sorry for so many questions... 😶



    <?php
    $size =& JFactory::getInt('text_14', '', 'post');
    $fish =& JRequest::getVar('check0', '', 'post');
    . . .
    $marker = $size."\n".$fish."\n". . . .;
    JRequest::setVar('marker', $marker);
    ?>
GreyHead 26 Aug, 2010
Hi yaksushi ,

Click the form name in the Forms Manager to open the Form Editor and the OnSubmit boxes are on the Form Code tab.

The name of your check-box array is check0 (the id's are check00, etc.)

I'm not sure if you will get a string back or an array, you'll soon find out.

Bob
yaksushi 26 Aug, 2010
wow bob thanks again for the very fast response!

what about the drop down boxes how can I capture the yes or no responses?
yaksushi 26 Aug, 2010
Ok I feel like a retard...

First will this code work? Or am I putting it in the wrong place because Im getting errors.

<?php
$size =& JFactory::getInt('text_14', 'post');
$fish =& JRequest::getVar('check00', 'check01', 'check02', 'check03', 'check04', 'post');
$parking =& JRequest::getVar('select_16', 'post');
$launch =& JRequest::getVar('select_17', 'post');
$cart =& JRequest::getVar('select_18', 'post');
$camp =& JRequest::getVar('select_19', 'post');
$difficulty =$ JRequest::getVar('select_12', 'post');
$marker = $size."\n".$fish."\n".$parking."\n".$launch."\n".$cart."\n".$camp."\n".$difficulty."\n";
JRequest::setVar('marker', $marker);
?>


I think I might be also putting the new code in the wrong place where exactly do I put my new code?
Do I put it in this block?

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


😢 😶
GreyHead 26 Aug, 2010
Hi yaksushi ,

This line is definitely wrong
$fish =& JRequest::getVar('check00', 'check01', 'check02', 'check03', 'check04', 'post');


Echo out $marker (or other variables) to see what is in it
$mainframe->enqueuemessage('$marker: '.print_r($marker, true));


Then you can debug as necessary.

Bob
yaksushi 26 Aug, 2010
well maybe this is just too far over my head...

This is what I have so far.

<div class="form_item">
  <div class="form_element cf_heading">
    <h1 class="cf_text">Fishing Location Form</h1>
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_textbox">
    <label class="cf_label" style="width: 150px;">Location Name:</label>
    <input class="cf_inputbox" maxlength="150" size="30" title="" id="text_4" name="title" type="text" />
  
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_textbox">
    <label class="cf_label" style="width: 150px;">latitude :</label>
    <input class="cf_inputbox required" maxlength="150" size="30" title="" id="text_1" name="latitude" type="text" />
  
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_textbox">
    <label class="cf_label" style="width: 150px;">longitude :</label>
    <input class="cf_inputbox required" maxlength="150" size="30" title="" id="text_2" name="longitude" type="text" />
  
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_heading">
    <h3 class="cf_text">Site Attributes</h3>
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_textbox">
    <label class="cf_label" style="width: 150px;">Acres:</label>
    <input class="cf_inputbox validate-number" maxlength="150" size="30" title="" id="text_14" name="description" type="text" />
  
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_checkbox">
    <label class="cf_label" style="width: 150px;">Target Fish:</label>
    <div class="float_left">
      <input value="Bass" title="" class="radio validate-one-required" id="check00" name="check0[]" type="checkbox" />
      <label for="check00" class="check_label">Bass</label>
      <br />
      
<input value="Catfish" title="" class="radio validate-one-required" id="check01" name="check0[]" type="checkbox" />
      <label for="check01" class="check_label">Catfish</label>
      <br />
      
<input value="Gar" title="" class="radio validate-one-required" id="check02" name="check0[]" type="checkbox" />
      <label for="check02" class="check_label">Gar</label>
      <br />
      
<input value="Drum" title="" class="radio validate-one-required" id="check03" name="check0[]" type="checkbox" />
      <label for="check03" class="check_label">Drum</label>
      <br />
      
<input value="Trout" title="" class="radio validate-one-required" id="check04" name="check0[]" type="checkbox" />
      <label for="check04" class="check_label">Trout</label>
      <br />
      

    </div>
    
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_dropdown">
    <label class="cf_label" style="width: 150px;">Parking:</label>
    <select class="cf_inputbox validate-selection" id="select_16" size="1" title=""  name="description">
    <option value="">Choose Option</option>
      <option value="Yes">Yes</option>
<option value="No">No</option>

    </select>
    
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_dropdown">
    <label class="cf_label" style="width: 150px;">Launch/Ramp Fees:</label>
    <select class="cf_inputbox validate-selection" id="select_17" size="1" title=""  name="description">
    <option value="">Choose Option</option>
      <option value="Yes">Yes</option>
<option value="No">No</option>

    </select>
    
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_dropdown">
    <label class="cf_label" style="width: 150px;">Kayak cart needed:</label>
    <select class="cf_inputbox validate-selection" id="select_18" size="1" title=""  name="select_18">
    <option value="">Choose Option</option>
      <option value="Yes">Yes</option>
<option value="No">No</option>

    </select>
    
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_dropdown">
    <label class="cf_label" style="width: 150px;">Camping Available:</label>
    <select class="cf_inputbox validate-selection" id="select_19" size="1" title=""  name="description">
    <option value="">Choose Option</option>
      <option value="Yes">Yes</option>
<option value="No">No</option>

    </select>
    
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_dropdown">
    <label class="cf_label" style="width: 150px;">Difficulty:</label>
    <select class="cf_inputbox validate-selection" id="select_20" size="1" title=""  name="description">
    <option value="">Choose Option</option>
      <option value="Easy">Easy</option>
<option value="Moderate">Moderate</option>
<option value="Hard">Hard</option>

    </select>
    
  </div>
  <div class="cfclear"> </div>
</div>

<input value="1" id="hidden_5" name="displaygps" type="hidden" />

<input value="0" id="hidden_7" name="icon" type="hidden" />

<input value="0" id="hidden_6" name="markerwindow" type="hidden" />

<input value="0" id="hidden_9" name="published" type="hidden" />

<input value="1" id="hidden_8" name="catid" type="hidden" />

<div class="form_item">
  <div class="form_element cf_button">
    <input value="Submit Location" name="button_17" type="submit" />
  </div>
  <div class="cfclear"> </div>
</div>



and this in On Submit code - before sending email:
<?php
$size =& JFactory::getInt('text_14', '', 'post');
$fish =& JRequest::getVar('check00', 'check01', 'check02', 'check03', 'check04', 'post');
$parking =& JRequest::getString('select_16','post');
$launch =& JRequest::getString('select_17','post');
$cart =& JRequest::getString('select_18','post');
$camp =& JRequest::getString('select_19','post');
$difficulty =$ JRequest::getString('select_12','post');
$description = $size."\n".$fish."\n".$parking."\n".$launch."\n".$cart."\n".$camp."\n".$difficulty."\n";
JRequest::setVar('description', $description);
?>



I can't figure out how to pass the combined values from the text boxes, radio buttons, and drop down boxes into the Field Name: "description"

I'm not even sure what the output looks like or if the values are combining.

Thanks for helping out a meat head!
yaksushi 27 Aug, 2010
Ok I've figured it out a little, this is what I have so far. Everything works except text_14, I'm unable to add text it with without it erroring out. Any ideas? It's like I'm unable to add text.
<?php
$size =& JFactory::getInt('text_14', '', 'post');
$fish =& JRequest::getVar('check0', 'post');
$parking =& JRequest::getString('select_16','post');
$launch =& JRequest::getString('select_17','post');
$cart =& JRequest::getString('select_18','post');
$camp =& JRequest::getString('select_19','post');
$difficulty =& JRequest::getString('select_20','post');
$marker = "<strong>Size:</strong>".$size."<br />"."<strong>Target Fish:</strong>".$fish."<br />"."<strong>Parking:</strong>".$parking."<br />"."<strong>Launch Fees:</strong>".$launch."<br />"."<strong>Kayak Cart Needed:</strong>".$cart."<br />"."<strong>Camping Available:</strong>".$camp."<br />"."<strong>Difficulty:</strong>".$difficulty."<br />";
JRequest::setVar('description', $marker);
?>

<div class="form_item">
  <div class="form_element cf_heading">
    <h1 class="cf_text">Fishing Location Form</h1>
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_textbox">
    <label class="cf_label" style="width: 150px;">Location Name:</label>
    <input class="cf_inputbox" maxlength="150" size="30" title="" id="text_4" name="title" type="text" />
  
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_textbox">
    <label class="cf_label" style="width: 150px;">latitude :</label>
    <input class="cf_inputbox required" maxlength="150" size="30" title="" id="text_1" name="latitude" type="text" />
  
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_textbox">
    <label class="cf_label" style="width: 150px;">longitude :</label>
    <input class="cf_inputbox required" maxlength="150" size="30" title="" id="text_2" name="longitude" type="text" />
  
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_heading">
    <h3 class="cf_text">Site Attributes</h3>
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_textbox">
    <label class="cf_label" style="width: 150px;">Acres:</label>
    <input class="cf_inputbox validate-number" maxlength="150" size="30" title="" id="text_14" name="text_14" type="text" />
  
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_checkbox">
    <label class="cf_label" style="width: 150px;">Target Fish:</label>
    <div class="float_left">
      <input value="Bass" title="" class="radio validate-one-required" id="check00" name="check0[]" type="checkbox" />
      <label for="check00" class="check_label">Bass</label>
      <br />
      
<input value="Catfish" title="" class="radio validate-one-required" id="check01" name="check0[]" type="checkbox" />
      <label for="check01" class="check_label">Catfish</label>
      <br />
      
<input value="Gar" title="" class="radio validate-one-required" id="check02" name="check0[]" type="checkbox" />
      <label for="check02" class="check_label">Gar</label>
      <br />
      
<input value="Drum" title="" class="radio validate-one-required" id="check03" name="check0[]" type="checkbox" />
      <label for="check03" class="check_label">Drum</label>
      <br />
      
<input value="Trout" title="" class="radio validate-one-required" id="check04" name="check0[]" type="checkbox" />
      <label for="check04" class="check_label">Trout</label>
      <br />
      

    </div>
    
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_dropdown">
    <label class="cf_label" style="width: 150px;">Parking:</label>
    <select class="cf_inputbox validate-selection" id="select_16" size="1" title=""  name="select_16">
    <option value="">Choose Option</option>
      <option value="Yes">Yes</option>
<option value="No">No</option>

    </select>
    
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_dropdown">
    <label class="cf_label" style="width: 150px;">Launch/Ramp Fees:</label>
    <select class="cf_inputbox validate-selection" id="select_17" size="1" title=""  name="select_17">
    <option value="">Choose Option</option>
      <option value="Yes">Yes</option>
<option value="No">No</option>

    </select>
    
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_dropdown">
    <label class="cf_label" style="width: 150px;">Kayak cart needed:</label>
    <select class="cf_inputbox validate-selection" id="select_18" size="1" title=""  name="select_18">
    <option value="">Choose Option</option>
      <option value="Yes">Yes</option>
<option value="No">No</option>

    </select>
    
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_dropdown">
    <label class="cf_label" style="width: 150px;">Camping Available:</label>
    <select class="cf_inputbox validate-selection" id="select_19" size="1" title=""  name="select_19">
    <option value="">Choose Option</option>
      <option value="Yes">Yes</option>
<option value="No">No</option>

    </select>
    
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_dropdown">
    <label class="cf_label" style="width: 150px;">Difficulty:</label>
    <select class="cf_inputbox validate-selection" id="select_20" size="1" title=""  name="select_20">
    <option value="">Choose Option</option>
      <option value="Easy">Easy</option>
<option value="Moderate">Moderate</option>
<option value="Hard">Hard</option>

    </select>
    
  </div>
  <div class="cfclear"> </div>
</div>

<input value="1" id="hidden_5" name="displaygps" type="hidden" />

<input value="0" id="hidden_7" name="icon" type="hidden" />

<input value="0" id="hidden_6" name="markerwindow" type="hidden" />

<input value="0" id="hidden_9" name="published" type="hidden" />

<input value="1" id="hidden_8" name="catid" type="hidden" />

<div class="form_item">
  <div class="form_element cf_button">
    <input value="Submit Location" name="button_17" type="submit" />
  </div>
  <div class="cfclear"> </div>
</div>
GreyHead 28 Aug, 2010
Hi yaksushi,

You've got getInt() here so it will only return if the input is an integer. Try setting a default value of zero instead of ''
$size =& JFactory::getInt('text_14', 0, 'post');


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