Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #8508
| From | "Jesolo Sun" <gala@tiscali.it> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Jquery to create 2 or multiple events in .change |
| Date | 2011-11-21 11:21 +0100 |
| Message-ID | <4eca261b$0$1382$4fafbaef@reader2.news.tin.it> (permalink) |
| Organization | TIN.IT (http://www.tin.it) |
I have first selectbox
<select id="stampa" name="stampa" onChange="calculateTotal();">
<option>Scegli...</option>
</select>
with Jquery i have 1 event with .change
$(document).ready(function(){
$("select#stampa").change(function(){
var stampa = $("select#stampa option:selected").attr('value');
$.post("select.php", {PrinttypeID:stampa}, function(data){
$("select#colori").removeAttr("disabled");
$("select#colori").html(data);
});
});
after with select.php built the query
$opt = new SelectList();
if(isset($_POST['PrinttypeID']))
{
echo $opt->ShowColori();
die;
}
this query populate the <option... in the selectbox id="colori"
<select id="colori" name="colori" onChange="calculateTotal();">
<option>Scegli...</option>
</select>
public function ShowColori()
{
include("sqlprotect.php");
$sql_colori = new sqlprotect();
$sql->secureGlobals();
$sql_colori = "SELECT printtype.PrinttypeID, printtype.Printtype,
printtype_colors.PrinttypeColors as colors,
printtype_colors.PrinttypeColorsID as ID
FROM printtype
LEFT JOIN printtype_colors ON printtype_colors.PrinttypeID =
printtype.PrinttypeID
WHERE printtype_colors.PrinttypeID=".$_POST[PrinttypeID]."
ORDER BY printtype_colors.PrinttypeColors
";
$res_colori = mysql_query($sql_colori,$this->conn);
$colori = '<option value="0">scegli...</option>';
while($row_colori = mysql_fetch_array($res_colori))
{
$colori .= '<option value="' . $row_colori['ID'] . '">' .
utf8_encode($row_colori['colors']) . '</option>\n';
}
return $colori;
}
I need to create an second event in $("select#stampa").change(function()
$(document).ready(function(){
$("select#stampa").change(function(){
var stampa = $("select#stampa option:selected").attr('value');
$.post("select.php", {PrinttypeID:stampa}, function(data){
$("select#colori").removeAttr("disabled");
$("select#colori").html(data);
});
});
I need to build another query.
If i create in this get me the error in the creation of the <option> value
if(isset($_POST['PrinttypeID']))
{
echo $opt->ShowColori();
echo $opt->ShowCosti();
die;
}
The second event at the .change is this:
if(isset($_POST['Quantity']))
{
echo $opt->ShowCosti($_POST['Printtype'],$_POST['Quantity'] );
die;
}
public function ShowCosti($PrinttypeID, $Quantita)
{
include("sqlprotect.php");
$sql_range_prezzo = new sqlprotect();
$sql->secureGlobals();
$sql_range_prezzo = " SELECT range_prezzo, range_aggiuntivo
FROM rangeprice
WHERE PrinttypeID = ".$PrinttypeID."
AND ".$Quantita." between scaglione_range_da AND
scaglione_range_a
";
$res_range_prezzo = mysql_query($sql_range_prezzo,$this->conn) or die
("Query Failed ".mysql_error(). print $sql_range_prezzo);
while($row_range_prezzo = mysql_fetch_array($res_range_prezzo))
{
$range_prezzo = '<input name="costi" id="costi" type=" text"
value="' . $row_range_prezzo['range_prezzo'] . '"
onchange="calculateTotal();"><br />';
$range_prezzo .= '<input name="costi_agg" id="costi_agg"
type="text" value="' . $row_range_prezzo['range_aggiuntivo'] . '"
onchange="calculateTotal();"><br />';
}
return $range_prezzo;
}
My question is : How to create a 2 or multiple events in
$("select#stampa").change(function() for to create 2 or multiple query?
Back to comp.lang.javascript | Previous | Next — Next in thread | Find similar | Unroll thread
Jquery to create 2 or multiple events in .change "Jesolo Sun" <gala@tiscali.it> - 2011-11-21 11:21 +0100
Re: Jquery to create 2 or multiple events in .change Scott Sauyet <scott.sauyet@gmail.com> - 2011-11-21 05:31 -0800
Re: Jquery to create 2 or multiple events in .change Gregor Kofler <usenet@gregorkofler.com> - 2011-11-21 23:32 +0100
Re: Jquery to create 2 or multiple events in .change Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-11-22 01:12 +0100
Re: Jquery to create 2 or multiple events in .change Scott Sauyet <scott.sauyet@gmail.com> - 2011-11-22 06:54 -0800
Re: Jquery to create 2 or multiple events in .change Scott Sauyet <scott.sauyet@gmail.com> - 2011-11-23 18:16 -0800
csiph-web