Have form that has a select list, change button, textarea and submit button. When page is loaded PHP sets up variables, and the textarea and submit button are disabled with the textarea displaying placeholder text.
What should happen is when the user selects an item from the list and then presses the change button, a javasript function inserts the selected text into a previously declared PHP variable, enables the textarea and submit button and inserts the variable into the text area.
This worked fine yesterday, but today, although nothing has changed all that happens is the textarea flashes and returns to the initial load state. The Firefox debugger shows the js function does change the variable.
Can someone who understands JS point me in the correct direction please? Thank you
Initial PHP:
The form code
The Javasript
What should happen is when the user selects an item from the list and then presses the change button, a javasript function inserts the selected text into a previously declared PHP variable, enables the textarea and submit button and inserts the variable into the text area.
This worked fine yesterday, but today, although nothing has changed all that happens is the textarea flashes and returns to the initial load state. The Firefox debugger shows the js function does change the variable.
Can someone who understands JS point me in the correct direction please? Thank you
Initial PHP:
PHP:
<?php
// Was it called correctly?
if (!isset($_GET["wl_id"])) {
header('location: home.php');
} else {
$wl_id = $_GET["wl_id"];
}
require_once 'session.php';
require_once 'conn.php';
require_once 'account_name.php';
$counter = 0;
if ($counter == 0) {
//SELECT statements and setup variable done here
++$counter;
$posted = false;
}
?>
The form code
Code:
<div class="alert alert-success">
<a class = "btn btn-success" href = "wl_fulllist.php"><span class = "fa fa-arrow-left"></span> Back</a>
<form id="frmInvite" name="frmInvite" class="form-horizontal" method = "POST">
<br />
<div class="form-group sm row alert alert-success">
<label class="col-md-2 offset-md-1 control-label" for="classday">Day:</label>
<div class="col-md-3">
<select class="form-control" id="classSelect">
<?php
while ($row = $c_query->fetch_assoc()) {
echo "<option value = " . $row['class_name'] . ">" . $row['class_name'] . "</option>";
}
?>
</select>
</div>
<button id= "btnSelect" name= "btnSelect" class="btn btn-primary btn-sm"><span class = "fa fa-check"></span> Select</button>
</div>
<div class="form-group sm row alert alert-success">
<label class="col-md-2 control-label" for="email">Email to:</label>
<div class="col-md-4">
<input id="invite_email" required name="invite_email" class="form-control input-sm" type="text" value="<?php echo $Email; ?>">
</div>
<label class="col-md-2 control-label" for="email">Subject:</label>
<div class="col-md-4">
<input id="Invite_subject" required name="Invite_subject" class="form-control input-sm" type="text" value="<?php echo $offertitle; ?>">
</div>
</div>
<div class="form-group sm row alert alert-success">
<textarea class="form-control" id="invite_txt" name="invite_txt" rows="7" placeholder = "Please select session" disabled = "disabled"></textarea>
</div>
<div class="modal-footer">
<button type="submit" id= "invite_btn" name="invite_btn" value = "invite" class="btn btn-primary" disabled = "disabled"><span class = "fa fa-upload"></span> Send</button>
</div>
</form>
</div>
The Javasript
JavaScript:
<script src = "js/jquery-3.1.1.js"></script>
<script src = "js/bootstrap.js"></script>
<script src = "js/script.js"></script>
<script>
$("#btnSelect").click(function () {
var e = document.getElementById("classSelect");
var x = e.options[e.selectedIndex].text;
<?php
echo 'var str ="' . $invitetext . '";';
?>
var res = str.replace("[****]", x);
document.getElementById("invite_txt").disabled = false;
document.getElementById("invite_btn").disabled = false;
$("#invite_txt").val(res);
return false;
});
</script>