SELECT & VIEW CHECKBOX
Hello everyone!
I have a page in PHP that receives several fields the user has entered into a form and selects the corresponding entries
from the Mysql database I have set up.
What I want to do is have something like a "SELECT & VIEW ENTRIES" checkbox, where the user can tick and view as many of the
entries returned he/she wants.
That is, if the database returns for example 10 entries that match ths user's query, I want to have a checkbox next to each entry
and if this checkbox is ticked, then the user will see the whole entry.
JeevesBond posted this at 13:34 — 23rd January 2006.
He has: 3,956 posts
Joined: Jun 2002
That's not feasible with the forms available at the moment, you could write a custom Flash movie, but that's generally a bad idea as it'll be more difficult to maintain and less accessible/usable (not everyone uses Flash and will also not expect to see checkboxes on a drop-down).
The simplest way around this is to use a select that allows multiple selections, you do this using the "multiple" attribute. For example:
<form action="index.html">
<select name="funtybunt" multiple="multiple">
<option>Funtybunt</option>
<option>Funtybunt Again</option>
</select>
</form>
Plop this code into an HTML page, then open it, you'll see a list box with both these values in. Hold down control and click each of them in turn, both will be selected.
Hopefully this will do what you want!
a Padded Cell our articles site!
Busy posted this at 20:28 — 23rd January 2006.
He has: 6,151 posts
Joined: May 2001
If you don't have the select option you can do it, two ways come to mind.
1/ depending on the length of the result (maybe a whole book) you could just retrieve say the first 100 characters from database and use the checkbox beside each result, on submit they would open up (with another database query) or.
2/ with a bit of javascript do the same as above but output the whole result but hide the result after 100 characters with javascript and when checkbox click the whole result is shown without page reloading or another query. down side is if javascript disabled the whole thing may not be readable.
Thinking about it, you could use the select option to choose results, if the selects options where like: view 10 results on apples, or view newest members ... it would act like a predefined search query
MyFreeCounter posted this at 01:12 — 28th January 2006.
They have: 7 posts
Joined: Jan 2006
I think the best option for you would be to do something with javascript. example:
<script>
var return_values=new Array(3);
return_values[0]="the value for your first returned row. blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah";
return_values[1]="the value for your second returned row. blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah";
return_values[2]="the value for your third returned row. blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah";
function checkClick(id,checkbox,cell) {
if (checkbox.checked==true)
cell.innerHTML=return_values[id];
else
cell.innerHTML=return_values[id].substr(0,50)+"..."; //show the first 50 characters
}
</script>
<form name=frm1>
<table style="width: 310px">
<tr>
<td style="width: 300px"><b>Returned Value</b></td>
<td style="width: 10px"></td>
</tr>
<tr>
<td id="row_0"></td>
<td><input type=checkbox name="ckbox_0" onclick="checkClick(0,this,document.getElementById('row_0'))"></td>
</tr>
<tr>
<td id="row_1"></td>
<td><input type=checkbox name="ckbox_1" onclick="checkClick(1,this,document.getElementById('row_1'))"></td>
</tr>
<tr>
<td id="row_2"></td>
<td><input type=checkbox name="ckbox_2" onclick="checkClick(2,this,document.getElementById('row_2'))"></td>
</tr>
</table>
</form>
<script>
//populate the cells
checkClick(0,document.frm1.ckbox_0,document.getElementById('row_0'));
checkClick(1,document.frm1.ckbox_1,document.getElementById('row_1'));
checkClick(2,document.frm1.ckbox_2,document.getElementById('row_2'));
</script>
Matt Pegler
MyFreeCounter Owner/Operator
http://www.myfreecounter.net
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.