Passing Hidden Value in Jquery to .cfc through Submit

I would like to pass the value of issendnow = -1 when the user clicks "Make Recurring". This is what I have so far.

My form info: (issendnow will be 1 unless 'Make Recurring' is clicked)

                 
<form class="smart-form" id="group-form" name="group-form" action="#event.buildLink('MassEmail.SendMassMessage')#"    method="post"  enctype="multipart/form-data">
                    <input type="hidden" value="1" name="sendto" id="sendTo" />
                    <input type="hidden" name="issendnow" id="issendnow" value="1" />

Open in new window


My Submit (I have more than one, thus have to do it this way):

<button type="submit" class="btn btn-warning" onclick="updateRecurring();"> Make Recurring </button>

Open in new window


My Jquery:

// recurring message 
function updateRecurring(){
$("##group-form").issendnow.value='-1';
return true;
}

Open in new window


What's interesting - and a bit confusing to me - is my .cfc isn't reading issendnow either way (and it's a hidden field with a value. I keep getting "key [ISSENDNOW] doesn't exist" when I get to this line

<cfif rc.issendnow EQ 1>

Open in new window


Perhaps I'm doing something wrong there?

Any help would be greatly appreciated!
tryportAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Hans LangerCommented:
Instead of a "submit button"
<button type="submit" class="btn btn-warning" onclick="updateRecurring();"> Make Recurring </button>

Open in new window

use just a "button"
<button type="button" class="btn btn-warning" onclick="updateRecurring();"> Make Recurring </button>

Open in new window


and submit the form through javascript

function updateRecurring(){
$("#group-form #issendnow").val('-1');
$("#group-form").submit()
}

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
tryportAuthor Commented:
For some reason, this keeps telling me "ReferenceError: updateRecurring is not defined." ?

Thanks for your help!
tryportAuthor Commented:
Does anyone have any suggestions?
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

_agx_Commented:
Since you're using jQuery you could also use a bind instead of onClick.  As GERENTE said, switch to type "button", just be sure to remove the onClick call:

HTML
<form id="group-form">
<input id="issendnow" type="hidden" name="issendnow" value="1" />
<button id="recurringButton" type="button" class="btn btn-warning"> Make Recurring </button>
</form>

Open in new window


JavaScript

$('#recurringButton').click(function(){
    $("#issendnow").val('-1');
    // debugging only
    console.log("#issendnow = "+ $("#issendnow").val());
    $("#group-form").submit()
 });

Open in new window

tryportAuthor Commented:
_agx_

I just can't seem to get anything to work. I wonder if it's something in my other forms on the page... ? Here's the form in question:

<form class="smart-form" id="individualform" name="individualform" action="index.cfm/MassEmail/SendMassMessage" method="post" enctype="multipart/form-data">
<input type="hidden" value="3" name="sendto" id="sendTo" />
<input type="hidden" name="issendnow" id="issendnow" value="" />
<fieldset>
<legend><strong>Send To:</strong> Individuals</legend>
<section>
<label class="label">Individual(s)</label>
<label class="select">
<select multiple style="width:100%" name="userIDs" id="userIDs">
<option value="6201">Account, Demo</option>
<option value="14543">Adams, Jefferson</option>
</select>
</label>
<div class="note"> Choose one or more individuals to send this message to </div>
</section>
<section>
<label class="label">Carbon Copy (CC)</label>
<label class="select">
<select multiple style="width:100%" name="ccUserIDs" id="ccUserIDs">
<option value="6201">Account, Demo</option>
<option value="14543">Adams, Jefferson</option>
<option value="6222">Anderson, Jonathan</option>
</select>
</label>
<div class="note"> Choose one or more individuals to carbon copy (cc) this message to</div>
</section>
<section>
<label class="label">Blind Carbon Copy (BCC)</label>
<label class="select">
<select multiple style="width:100%" name="bccUserIDs" id="bccUserIDs">
<option value="6201">Account, Demo</option>
<option value="14543">Adams, Jefferson</option>
<option value="6222">Anderson, Jonathan</option>
</select>
</label>
<div class="note"> Choose one or more individuals to blind carbon copy (bcc) this message to</div>
</section>
<section>
<label class="label">Subject</label>
<label class="input">
<input type="text" name="subject" id="subject" maxlength="80" value="">
</label>
<div class="note"> Similar to an email on your computer; provide a brief overview of this email</div>
</section>
<section>
<label class="label">Message</label>
<label class="textarea textarea-resizable">
<textarea rows="12" name="msg3" id="msg3"></textarea>
</label>
</section>
<section>
<label class="label">Attachments</label>
<div class="input input-file"> <span class="button">
<input type="file" id="emailAttach" name="emailAttach" onchange="document.getElementById('emailattachlabel').value = this.value">
Browse</span>
<input type="text" id="emailattachlabel" placeholder="Include some files" readonly>
</div>
<div class="input input-file"> <span class="button">
<input type="file" id="emailAttach2" name="emailAttach2" onchange="document.getElementById('emailAttach2label').value = this.value">
Browse</span>
<input type="text" id="emailAttach2label" placeholder="Include some files" readonly>
</div>
<div class="input input-file"> <span class="button">
<input type="file" id="emailAttach3" name="emailAttach3" onchange="document.getElementById('emailAttach3label').value = this.value">
Browse</span>
<input type="text" id="emailAttach3label" placeholder="Include some files" readonly>
</div>
</section>
<section>
<label class="label">Also Deliver Message To</label>
<div class="inline-group">
<label class="checkbox">
<input type="checkbox" id="personalemail" name="personalemail">
<i></i>Personal Emails</label>
<label class="checkbox">
<input type="checkbox" id="eBox" name="eBox">
<i></i>eBox Message</label>
</div>
</section>
</fieldset>
<footer>
<button id="recurringButton" type="button" class="btn btn-warning"> Make Recurring </button>
<button type="submit" class="btn btn-primary">Send Now </button>
<button type="button" class="btn btn-default" onclick="window.history.back();"> Back </button>
</footer>
</form>
</div>

<script type="text/javascript">
$(document).ready(function() {
$('#recurringButton').click(function(){
$("#issendnow").val('-1');
// debugging only
console.log("#issendnow = "+ $("#issendnow").val());
$("#individualform").submit()
});
$(function() {
// Validation
$("#groupform").validate({
// Rules for form validation
rules : {
groupID : {
required : true
},
subject : {
required : true,
minlength : 3,
maxlength : 80
}
},
// Messages for form validation
messages : {
groupID : {
required : 'At least one group is required'
},
subject : {
required : 'Please provide a subject for this email message'
},
},
// Do not change code below
errorPlacement : function(error, element) {
error.insertAfter(element.parent());
}
});
});
$(function() {
// Validation
$("#individualform").validate({
// Rules for form validation
rules : {
userIDs : {
required : true
},
subject : {
required : true,
minlength : 3,
maxlength : 80
}
},
// Messages for form validation
messages : {
userIDs : {
required : 'At least one one individual is required'
},
subject : {
required : 'Please provide a subject for this email message'
},
},
// Do not change code below
errorPlacement : function(error, element) {
error.insertAfter(element.parent());
}
});
});
$(function() {
// Validation
$("#smartFilterform").validate({
// Rules for form validation
rules : {
locationID : {
required : true
},
deptID : {
required : true
},
userClassID : {
required : true
},
workStatusID : {
required : true
},
subject : {
required : true,
minlength : 3,
maxlength : 80
}
},
// Messages for form validation
messages : {
locationID : {
required : 'At least one one location is required; select All Locations to include all'
},
deptID : {
required : 'At least one one department is required; select All Departments to include all'
},
userClassID : {
required : 'At least one one user class/rank is required; select All User Classes to include all'
},
workStatusID : {
required : 'At least one one work status is required; select All Work Statuses to include all'
},
subject : {
required : 'Please provide a subject for this email message'
},
},
// Do not change code below
errorPlacement : function(error, element) {
error.insertAfter(element.parent());
}
});
});
$('select').select2();
})
</script>

Open in new window

_agx_Commented:
EDIT:

> $(function() {
> $(document).ready(function() {

Usually I place document.ready() stuff in the header.  Also, I'm not sure you can have both of those.  Try putting all of the "on load" stuff inside a single $(document).ready() call.

Is the form even submitting? I'd tackle it in steps, to figure out which step is causing the problem.

1) Check the js console for errors and verify it even reaches the button click
2) If so, temporarily submit the form to a test .cfm page. On that page, dump out the FORM/URL scopes so you can see what's actually submitted.  Verify the hidden form field value is there. If yes, it suggests the problem occurs w/the CFC part, so...

3) Switch back to the CFC and check the network tab of your JS console. What data/fields are actually submitted?


Might also be a problem with the cfc signature (or the framework you're using).  How are you submitting to the CFC and what does your function looks like?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
jQuery

From novice to tech pro — start learning today.