guillem
12-09-2009, 08:50 PM
hi everyone.
i'm driving myself mad with this... i dont know what i'm doing wrong. any help, thanks in advance! sorry to ask, but i couldnt find a way to do this in google. there are a lot of options out there, but seem too strange to me (requests, events observers, etc).
i want a page with 2 divs (div1, to hold the buttons, and div2, to get the results). In one of them, i put a select and two buttons, in the other, i just want the results: if the select changed, or which button was pressed.
i'm using prototype, but it seems not to work. i think it's the most suitable (and easy!!) to do what i want. kind of new with this...
ps: note the buttons are not submit.
i've done a function which sends the data of the form and sends it to a specific div to execute a specific php.
the code:
main html file:
<script src="utils/Scripts/prototype.js" type="text/javascript"></script>
<script type="text/javascript">
function sendf(formul, divi, php)
{
var params = Form.serialize($(formul));
new Ajax.Updater(divi, php, {method: 'post', parameters: params});
}
</script>
</head>
<body>
<div id="div1">
contenido div1
<form id="formulario" method="POST">
<select size="3" id="lista" onchange="sendf('formulario', 'div2', 'prodiv1.php');">
<option>elemento 1</option>
<option>elemento 2</option>
<option>elemento 3</option>
</select>
<input type="button" id="b1" value="bot1" onclick="sendf('formulario', 'div2', 'prodiv1.php');" />
<input type="button" id="b2" value="bot2" onclick="sendf('formulario', 'div2', 'prodiv1.php');" />
</form>
<div id="div2" style="background: blue;">
contenido div2
</div>
</div>
</body>
</html>
file: prodiv1.php
<?
echo 'exec: prodiv1.php<br>';
echo "select: ".$_POST['lista'];
if (isset($_POST['b1'])) {echo 'click: boton1';} else {echo 'click: boton2';}
?>
doesnt work, and i dont know what to do next!
any elegant solutions???
thanks again!!!
i'm driving myself mad with this... i dont know what i'm doing wrong. any help, thanks in advance! sorry to ask, but i couldnt find a way to do this in google. there are a lot of options out there, but seem too strange to me (requests, events observers, etc).
i want a page with 2 divs (div1, to hold the buttons, and div2, to get the results). In one of them, i put a select and two buttons, in the other, i just want the results: if the select changed, or which button was pressed.
i'm using prototype, but it seems not to work. i think it's the most suitable (and easy!!) to do what i want. kind of new with this...
ps: note the buttons are not submit.
i've done a function which sends the data of the form and sends it to a specific div to execute a specific php.
the code:
main html file:
<script src="utils/Scripts/prototype.js" type="text/javascript"></script>
<script type="text/javascript">
function sendf(formul, divi, php)
{
var params = Form.serialize($(formul));
new Ajax.Updater(divi, php, {method: 'post', parameters: params});
}
</script>
</head>
<body>
<div id="div1">
contenido div1
<form id="formulario" method="POST">
<select size="3" id="lista" onchange="sendf('formulario', 'div2', 'prodiv1.php');">
<option>elemento 1</option>
<option>elemento 2</option>
<option>elemento 3</option>
</select>
<input type="button" id="b1" value="bot1" onclick="sendf('formulario', 'div2', 'prodiv1.php');" />
<input type="button" id="b2" value="bot2" onclick="sendf('formulario', 'div2', 'prodiv1.php');" />
</form>
<div id="div2" style="background: blue;">
contenido div2
</div>
</div>
</body>
</html>
file: prodiv1.php
<?
echo 'exec: prodiv1.php<br>';
echo "select: ".$_POST['lista'];
if (isset($_POST['b1'])) {echo 'click: boton1';} else {echo 'click: boton2';}
?>
doesnt work, and i dont know what to do next!
any elegant solutions???
thanks again!!!