0
I’m using the Simplemodal Contact Form by Eric Martin, but I’m having a hard time passing a variable to the form
via get.
I wanted to, in the index.php
, I could send the variable $palestra_titulo
, and that this was used in the form in the "Subject" field, already appearing filled and being used to send by e-mail.
In index.php, the GET method would be passed through an image. It would be something like <a href='data/contact.php?article_id=<?php $id ?>' class="contact"><img src="x.gif"/></a>
.
In contact.js, I have an ajax function:
$.ajax({
url: 'data/contact.php',
data: $('#contact-container form').serialize() + '&action=send&',
type: 'post',
cache: false,
dataType: 'html',
success: function (data) {
$('#contact-container .contact-loading').fadeOut(200, function () {
$('#contact-container .contact-title').html('Obrigado!');
msg.html(data).fadeIn(200);
});
},
error: contact.error
});
And in contact.php, the snippet that displays the field is:
$action = isset($_POST["action"]) ? $_POST["action"] : "";
if (empty($action)) {
// Send back the contact form HTML
$output = "<div style='display:none'>
<div class='contact-top'></div>
<div class='contact-content'>
<h1 class='contact-title'>Inscreva-se Aqui</h1>
<div class='contact-loading' style='display:none'></div>
<div class='contact-message' style='display:none'></div>
<form action='#' style='display:none'>
<label for='contact-name'>*Nome:</label>
<input type='text' id='contact-name' class='contact-input' name='name' tabindex='1001' />
<label for='contact-email'>*E-mail:</label>
<input type='text' id='contact-email' class='contact-input' name='email' tabindex='1002' />";
if ($extra["form_subject"]) {
$output .= "
<label for='contact-subject'>Palestra:</label>
<input type='text' id='contact-subject' class='contact-input' name='subject' value='' tabindex='1003' />";
}
The value that should display the value of the $palestra_title variable is in the last line.
What changes in the contact.js
and contact.php
should do for this?
It is not good for you to print the variable in the attribute
value
ofinput
? Something like:<input value='<?php echo $palestra_titulo ?>'>...
– user7261
Welcome to the Sopt. Just to help you get used to our philosophy, which is different from a forum, take a look at pt.stackoverflow.com/help/behavior, especially 3rd. item. If not read yet, it would be good to take a look at [about], you win a medal. You can use [Edit] to leave your question in the way of a straight and clean question. Gradually you get used to it.
– Maniero