| | |
select/save selected records
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jul 2009
Posts: 2
Reputation:
Solved Threads: 0
hi, All
i have two options form; one hold $selection that select suburb from datadase and other $suburb which “Selected Records”.
when a suburb is double clicked, it should automatically be added to the corresponding selected section; and be removed from the selection list. The same with a record that is in “Selected Records”, when double clicked, it should be removed from the “Selected Records” section, back to the “Selection List”. and i managed to do that by javascript but i can't select/save "selected records" from database. please help
notice.php
i have two options form; one hold $selection that select suburb from datadase and other $suburb which “Selected Records”.
when a suburb is double clicked, it should automatically be added to the corresponding selected section; and be removed from the selection list. The same with a record that is in “Selected Records”, when double clicked, it should be removed from the “Selected Records” section, back to the “Selection List”. and i managed to do that by javascript but i can't select/save "selected records" from database. please help
notice.php
<script type="javascript">
function RightButton_OnClick()
{
var AvailableLB = document.getElementById("selection");
var LinkedLB = document.getElementById("suburb");
for (var i=0; i < AvailableLB.length; i++)
{
if (AvailableLB.options[i].selected == true)
{
LinkedLB.options[LinkedLB.length] = new Option(AvailableLB.options[i].text,AvailableLB.options[i].value);
AvailableLB.options[i] = null;
i=i-1;
}
}
return;
}
function LeftButton_OnClick(LinkedLB)
{
var AvailableLB = document.getElementById("selection");
var LinkedLB = document.getElementById("suburb");
for (var i=0; i < LinkedLB.length; i++)
{
if (LinkedLB.options[i].selected == true)
{
AvailableLB.options[AvailableLB.length] = new Option(LinkedLB.options[i].text,LinkedLB.options[i].value);
LinkedLB.options[i] = null;
i=i-1;
}
}
return;
}
</script>
<?php
include("dbconnect.php");
$query ="select distinct suburb from customers order by suburb ";
$result = mysql_query($query) or die (mysql_error());
?>
<!-- send notifyme notice -->
<form action="process_notice.php" method="post" >
<table style="margin:15px">
<tr>
<td>
<p style="margin:0;">Select suburb</p>
<select name="selection[]" id="selection" multiple size="8" ondblclick="RightButton_OnClick();" style="width:160px">
<?php
while ($row = mysql_fetch_array($result))
{
echo "<option>".ucwords($row[0])."</option>";
}
?>
</select>
</td>
<td>
<input name="moveRight" type="button" value=">>" onClick="RightButton_OnClick();"><br />
<input name="moveLeft" type="button" value="<<" onClick="LeftButton_OnClick();">
</td>
<td>
<p style="margin:0;">Selected Records</p>
<select name="suburb[]" id="suburb" size="8" multiple ondblclick="LeftButton_OnClick();" style="width:160px">
</select>
</td>
</tr>
</table>
process_notice.php
if ($_POST['notice'] !='' || isset($notice))
{
if ($_POST['suburb']!="Please select a suburb" && $_POST['suburb']!='')
{
$suburb= $_POST[suburb];
for($i=0; $i<$suburb; $i++)
{
// send notification
include("dbconnect.php");
$notice=$_POST['notice'];
// To retrieve array
$query ="select cell,count(cell) as numcell from customers where suburb='$suburb[$i]' group by suburb";
$result = mysql_query($query) or die (mysql_error());
if(mysql_num_rows($result))
{
while ($row = mysql_fetch_array($result))
{
echo "<input name=\"suburb\" type=\"hidden\" value=\"<?php echo $row[suburb];?>\">";
echo "<p> You have sent <span id=\"sentnumber\">".$row[numcell]."</span> people a notification to this suburb: $suburb[$i]</p>";
echo "<p> Notice: $notice </p>";
}
} else {
echo "<p id=\"error_msg\" >Error: no suburb in database</p>";
}
exit;
}
} else {
echo "<p id=\"error_msg\" >Please select a suburb</p>";
exit;
}
} else {
echo "<p id=\"error_msg\" >Please type in your notice</p>";
exit;
} Last edited by ~s.o.s~; Aug 28th, 2009 at 7:22 am. Reason: Added code tags, learn to use them.
![]() |
Similar Threads
- How To Save/Download A Short Movie Clip (Windows 95 / 98 / Me)
- How to select value in datagrid and use it to retrive records from database (VB.NET)
- how to select last record from 'thousands of records' using sql query (JavaScript / DHTML / AJAX)
- Need to press submit button two times to save records (ASP.NET)
- save selected radio button value in session scoped bean (JSP)
- memory management in wndows 2000 (Windows NT / 2000 / XP)
- collection_select with :selected option (Ruby)
- how to retrieve textfield for more than 1 checked records? (ASP)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: javascript form validation
- Next Thread: Setting text field to accept only alphabetical characters.
| Thread Tools | Search this Thread |
acid2 ajax ajaxexample ajaxjspservlets array beta box browser captchaformproblem cart child close codes column css date debugger decimal dependent design disablefirebug dom download element embed engine enter error events ext file firefox focus form forms frameworks getselection google gwt gxt hiddenvalue highlightedword hint html ie7 ie8 iframe index java javascript javascripthelp2020 jquery jsp jump libcurl listbox maps masterpage math media menu microsoft mimic mp4 onerror onmouseoutdivproblem onmouseover onreadystatechange paypal pdf php position post problem programming prototype rated rating redirect safari scale scriptlets scroll search security select software star starrating synchronous toggle unicode variables w3c web webservice window windowofwords xml \n





