PDA

View Full Version : Prediction score insert



Sjf0464
11-03-2017, 11:12 AM
Hi,

I have had a few requests from user on our site to see if it's possible to change the prediction page.
At the moment users put their prediction into a text box, could this be changed to possibly a drop box showing possible score, 1, 2, 3, 4 etc instead. Users then click on a score for that team.
It was mentioned to me as a few users play on their phones and have to keep changing from Alpha to Numeric for each insert.
Hope this makes sense.
Regards

kostas
13-03-2017, 10:02 AM
Hello,

to change the textbox to dropdown change the code in file <joomla directory>/components/com_masterleaguepro/views/matches/tmpl/default.php

lines 56~58



<td><?php
echo "<input type='text' name='jform[home_team_score][".$match->match_id."]' value='".$match->home_prediction."' min='0'/> - <input type='text' value='".$match->away_prediction."' name='jform[away_team_score][".$match->match_id."]' min=0 />";
?></td>


to



<td>
<select name='jform[home_team_score][<?php echo $match->match_id;?>]' style='max-width: 110px;'>
<option value=''>Select Score</option>
<?php for($sc=0;$sc<=20;$sc++): ?>
<option value='<?php echo $sc; ?>'<?php echo $sc==$match->home_prediction?" selected='selected'":""; ?>><?php echo $sc; ?></option>
<?php endfor;?>
</select>


-


<select name='jform[away_team_score][<?php echo $match->match_id;?>]' style='max-width: 110px;'>
<option value=''>Select Score</option>
<?php for($sc=0;$sc<=20;$sc++): ?>
<option value='<?php echo $sc; ?>'<?php echo $sc==$match->away_prediction?" selected='selected'":""; ?>><?php echo $sc; ?></option>
<?php endfor;?>
</select>
</td>


this code will display instead of text fields a drop down with options from 0 to 20

Best Regards

Sjf0464
14-03-2017, 10:21 PM
many thanks, have changed the code and works great for the league. 20 was too many so changed to 9.
Will this have changed the code for the championship also ? we do not have championship games due for a while so cannot check. If it does not change the championship also, which file do I need to change and is it the same code ?
Regards

kostas
16-03-2017, 12:26 PM
to have the same functionality in the championship you will have to change code in another file (same change)
<joomla-installation>/components/com_masterleaguepro/views/minileaguematches/tmpl/default.php

lines 57~59


<td><?php
echo "<input type='text' name='jform[home_team_score][".$match->match_id."]' value='".$match->home_prediction."' min='0'/> - <input type='text' value='".$match->away_prediction."' name='jform[away_team_score][".$match->match_id."]' min=0 />";
?></td>


to



<td>
<select name='jform[home_team_score][<?php echo $match->match_id;?>]' style='max-width: 110px;'>
<option value=''>Select Score</option>
<?php for($sc=0;$sc<=20;$sc++): ?>
<option value='<?php echo $sc; ?>'<?php echo $sc==$match->home_prediction?" selected='selected'":""; ?>><?php echo $sc; ?></option>
<?php endfor;?>
</select>




-




<select name='jform[away_team_score][<?php echo $match->match_id;?>]' style='max-width: 110px;'>
<option value=''>Select Score</option>
<?php for($sc=0;$sc<=20;$sc++): ?>
<option value='<?php echo $sc; ?>'<?php echo $sc==$match->away_prediction?" selected='selected'":""; ?>><?php echo $sc; ?></option>
<?php endfor;?>
</select>
</td>

Sjf0464
24-03-2017, 07:31 PM
How do we change the drop down box to show Select Score as default and not 0, this way user will see which scores still need predicting, regards

Sjf0464
28-07-2017, 03:20 PM
Hi, just wondered if you have a resolve for the last post please, regards, steve

kostas
31-07-2017, 09:38 AM
Hello,

to make the default value "Select Score"

change the code from



<td>
<select name='jform[home_team_score][<?php echo $match->match_id;?>]' style='max-width: 110px;'>
<option value=''>Select Score</option>
<?php for($sc=0;$sc<=20;$sc++): ?>
<option value='<?php echo $sc; ?>'<?php echo $sc==$match->home_prediction?" selected='selected'":""; ?>><?php echo $sc; ?></option>
<?php endfor;?>
</select>
-
<select name='jform[away_team_score][<?php echo $match->match_id;?>]' style='max-width: 110px;'>
<option value=''>Select Score</option>
<?php for($sc=0;$sc<=20;$sc++): ?>
<option value='<?php echo $sc; ?>'<?php echo $sc==$match->away_prediction?" selected='selected'":""; ?>><?php echo $sc; ?></option>
<?php endfor;?>
</select>
</td>


to



<td>
<select name='jform[home_team_score][<?php echo $match->match_id;?>]' style='max-width: 110px;'>
<option value=''>Select Score</option>
<?php for($sc=0;$sc<=20;$sc++): ?>
<option value='<?php echo $sc; ?>'<?php echo $sc==$match->home_prediction&&$match->home_prediction!=""?" selected='selected'":""; ?>><?php echo $sc; ?></option>
<?php endfor;?>
</select>
-
<select name='jform[away_team_score][<?php echo $match->match_id;?>]' style='max-width: 110px;'>
<option value=''>Select Score</option>
<?php for($sc=0;$sc<=20;$sc++): ?>
<option value='<?php echo $sc; ?>'<?php echo $sc==$match->away_prediction&&$match->away_prediction!=""?" selected='selected'":""; ?>><?php echo $sc; ?></option>
<?php endfor;?>
</select>
</td>


Best Regards