So I am trying to submit a form using Jaunt. There are two submit buttons, a check and apply. I am Trying to click the check button but am having some trouble because it cant find the button with the identifier of "check".
I am basically copying what is done on the Jaunt tutorial #15,
http://jaunt-api.com/jaunt-tutorial.htm
I have tried the value of the button as well but to no luck
Code:
form.submit("Check");
Html:
<input name="action" class="a-button-input" type="submit" value="checkValue" aria-labelledby="gc-redemption-check-value-announce">
<span id="gc-redemption-check-value-announce" class="a-button-text" aria-hidden="true">
<span id="gc-redemption-check-value-button-text" class="a-size-base">Check</span>
</span>
If the Jaunt thing is not work maybe you can try jQuery
$('.submitButton').click(function(){
$('form').submit();
});
Related
I was working on a script for a chrome extension for supreme website. His function is to buy hightly demended items very quickly.
Everything work until one thing, I can't subit or click on the add to cart button. I tryed everything, click() function, submit() function, submit the <form> but it's didn't work.
The input (type: submit) don't have Id, just have a name and value.
That's the input form the web site :
<form id="cart-addf">
<!--Others inputs and fieldsets-->
<fieldset id="add-remove-buttons">
<input type="submit" name="commit" value="ajouter" class="button" /><!--That's what I want to submit-->
<a class="button continue" href="/shop">retour</a>
</fieldset>
I thought of retrieving the position of the input and simulating a click, but once again I can't get anything.
If somebody have a solution thank's !
I am trying to figure out the best approach to modifying a hidden django form field. Or if it's even possible. I had my HTML setup to accomplish this very task and it was working perfectly. However, in order to prevent multiple submissions I had to change my HTML and now I am unable to figure out how to pass a value via an HTML button depending on what the user clicks on.
Previously, I had two buttons defined as outline below:
<button type="submit" class="button1" name="status" value="Saved"><h3 class="txtalgn4">Save</h3></button>
<button type="submit" class="button2" name="status" value="Submitted"><h3 class="txtalgn4">Submit</h3></button>
As stated above, this worked perfectly for the purpose of passing a value to an attribute for my model. The value of status was saved as expected depending on which button the user clicked on.
Now I have updated the buttons to type="button" in response to this issue that I opened up today...How To Prevent Double Submit With Form Validation
I tried using the following code:
<button type="button" class="button1" name="status" value="Saved"><h3 class="txtalgn4">Save</h3></button>
<button type="button" class="button2" name="status" value="Submitted"><h3 class="txtalgn4">Submit</h3></button>
And then I also changed the status field to {{ status.as_hidden }} in my HTML to get the value. This only works if I hardcode the status value in my database structure. I need to be able to get this value dynamically depending on what the user clicks. Is JQuery with Ajax the right approach for this? Is there some simple way to modify the hidden field depending on which button the user clicks?
Is there some better way to go about trying to get this field in a hidden manner? As stated above the HTML way with type="submit" worked perfectly, but caused problems when I was trying to prevent the user from double submitting the form. As in all things programming I solved one problem and created another.
Thanks in advance for any thoughts.
Keep using two submit buttons like you were. But instead of disabling the buttons, you disable the whole form from submitting if once submitted.
First, give your form a unique html ID.
<form id="myform">
...
</form>
<!-- JS code -->
<script type="text/javascript">
$('#myform').on('submit', function(e) {
if ($(this).hasClass('submitted')) {
// prevent submission
e.preventDefault();
return;
}
$(this).addClass('submitted');
});
</script>
I am new to angular js and I am developing a form which has many input fields and two buttons- one for cancel and another one for submitting the form.
i am having a ng-submit="" on the form tag to recognize if the form is submitted and show some error messages.
Problem i am facing is when i click on enter 'cancel' button is triggered. How do i prevent this?
I tried adding type=input on the button but it does not work.
<button type="button" ng-click="function">Cancel</button>
I cannot change the button tag to input tag as i am applying some styles and i am losing them if i change the tag.
How do I achieve this?
Thanks in advance.
UPDATE:
below is the code for button.
<div class="button-group-right" style="width:49%; float:left">
<button class="btn btn-large btn-tertiary btn-right" ng-click="subnmitPage()">
<span class="btn-text">
<span class="btn-text-container">Submit</span>
</span>
<span class="btn-icon">
<i class="navigateright button-icon"></i>
</span>
</button>
</div>
i fixed it by adding $event in my function and saying preventDefault().
code below.
in html:
<button ng-click="subnmitPage($event)"/>
and in controller
$scope.subnmitPage=function(event){
event.preventDefault();
}
<form name="callEventForm" method="post" action="/PDC/callevent.do">
...
<input type="button" value="Save" name="addCallEvent" id="addCallEvent" onclick="alert('You clicked me!')"/>
...
</form>
When clicking this "Save" button, the form is submitted instead of displaying the alert. I was lead to believe that type="button" would cause the form to not submit on click.
Change:
onclick="alert('You clicked me!')"
To:
onclick="alert('You clicked me!');return false;"
I hate to answer my own questions but this was a weird one. There was an ajax:updateField tag that was overriding the onclick event of the button. Changing the source event of the ajax:updateField allowed my established onclick event to fire appropriately. I know that there's no way anyone would have caught that based on the code I posted, but the rest of the page is so much code that I would hate to make people wade through it.
I added a button that is supposed to open a calendar 'date-picker'. The button is in a form that is rendered inside an EXTJS TabPanel. When the button is clicked, it causes the EXTJS tab panel to reload. Even if I remove everything but the following (making it a dumb button) the page still reloads.
<button id="calendar-trigger">...</button>
Edited: derived from: http://www.dynarch.com/projects/calendar/doc/
<input type="text" id="id_activity_date" name="activity_date">
<input type="button" value="..." id="calendar-trigger">
<script type="text/javascript">
new Calendar({
trigger : "calendar-trigger",
inputField : "id_activity_date",
onSelect : function() { this.hide() }
});
</script>
I don't want the reload to happen and I can't figure out why the reload is happening. or how to stop it. Something is getting triggered beyond just the button click. I suspect that EXTJS is causing it, but I can't figure out why.
I would like to start by killing all code that is triggered by this button. I want to make this a dumb button that doesn't do anything when clicked.
What is likely going on here? and How can I fix it?
Try this instead:
<input type="button" id="calendar-trigger" value="Button Label">
I've had trouble with <button> tags trying to submit forms and what not when they should not. Using an <input> tag with a type of "button" seemed to help me - maybe it will work for you as well.
If you have a <button> tag on a form which does not have a submit button (<input type="submit">), the <button> becomes the input button by default, apparently.
In HTML, <button> has a type attribute. The default value for type is submit, meaning that unless you specify type="button" (or something else), the button will trigger the submission of the form it is associated with. That is probably what is causing your page to reload (because the form is being submitted).
Alternatively, you could use <input type="button" id="calendar-trigger" />.
I would recommend using <input> as opposed to <button>
<input type="button" value="Click Me" id="calendar-trigger" />
Typically the <input type="submit" /> will make a submit button when in a form, I suspect that is what the <button> tag is doing.