Skip to content

Using forms values in Modalbox

okonet edited this page Aug 25, 2010 · 5 revisions

Introduction

This is the explanation on passing form variables values to MB pages. For example we have the following form on one MB page:

<form action="yoururl.php" method="get" id="myform" onsubmit="return false">
	<fieldset>
		<label for="name">Your name</label>
		<input type="text" size="30" id="name" name="name" /><br />
		<label for="email">Email to</label>
		<input type="text" size="30" id="email" name="email" /><br />
	</fieldset>
	<input type="submit" value="Submit" onclick="Modalbox.show('yoururl.php', {title: 'Sending status', params: Form.serialize('myform') }); return false;" />
</form>

and then in youurl.php we’re doing the following:

<?php
	$name = $_GET['name'];
	$email = $_GET['email'];
?>
<h1><?php echo $name ?>, your message sent!</h1>

to show the sender name.

That’s all!

Details

See the working example here: http://okonet.ru/projects/modalbox/

Please note: http://prototypejs.org/api/form/serialize