The variable message in the script is returning undefined while the variable name is true... I want to actually the input text by from the name of the button clicked
<script type="text/javascript">
$(function() {
$(".submitcc").click(function() {
var name = $(this).attr("name");
var message = $("#" + name).val();
return false;
});
});
</script>
This is the form that is calling the script above...
<form method="post" action="">
<input type="text" name="message" id="submitcc_2_2" />
<button class="submitcc"name="submitcc_2_2">Send</button>
</form>
<form method="post" action="">
<input type="text" name="message" id="submitcc_5_2" />
<button class="submitcc"name="submitcc_5_2">Send</button>
</form>
is there something wrong?