Submit button with external link - wicket

I have two submit buttons inside a form:
<input class="submitButton button cancel" name="cancel"
value="Cancel" title="" type="submit">
<input class="submitButton button" name="Registrieren"
value="Register" title="Register" type="submit">
I would like the first button (cancel) to have a link to an external page. The link is known in the backend (FormController).
I had a look at the SubmitLink class. However it looks like that doesn't fit to my use case. I don't want to process the click on the "cancel" button in the backend, just redirect to the external page by integrating this dynamic link into the HTML file.

I agree with #jurgemaister that you can use <a> for the cancel button and style it with CSS to look like a button.
Otherwise you can add 'click' JavaScript listener to the cancel button to do something like location.href='/url/to/other/page'.

Related

How to goto back page on click of cancel button in ZUL apge

I wanted to navigate to the browsers back page (History) onclick of Back button. How I can achieve this usign zul page? I have one option of keeping the hidden field and redirect via composer or using zk's if condition. But any other solution like javascripts function are?
You can use client side javascript in combination with Java Script's history object:
<zk xmlns="http://www.zkoss.org/2005/zul">
<div>
<button label='back'
xmlns:w="client"
w:onClick="history.back();"
/>
</div>
</zk>

jquery ajax popup and return selected checkbox inside pop up form

Seems like a common question but could not find on this site. Must be due to my lack of experience in jquery or ajax.
I have a form like this:
<form id="form1">
+Add Item
</form>
when the person clicks "+Add Item" it pops up a new page which allows him to navigate and click the desired checkbox. Then it should insert in the above form something like:
<input type="hidden" name="item1_id" value="4">Item 1<br>
where value="4" would be the id of the checkbox checked.
any help would be greatly appreciated.
Don't use an anchor tag. Instead, create a div container for your pop up, which you can load dynamically:
$('#container').load('add-item.php');
Then add a listener to your item buttons append the result in your form:
$("#item_1").click(function() {
var $newinput = $("<input type='hidden' />");
$newinput.val(4);
$newinput.attr("name","item1_id")
$("#form1").append($newinput,"Item 1<br>");
});

Button Onclick does not work inside form

Good Day
I am using an ASP.NET webform where I have wrapped the following button inside the form tags:
<form runat="server">
<button class="btn btn-primary" onclick="window.location='http://google.co.za';">Login</button>
</form>
ISSUE: The problem is that when clicking on the button, it just directs to the current page...does not redirect. However, when I remove the form tags, the button works. If I leave the form tags and I use an anchor tag to relocate, it works as well...It is just the button that is giving me issues.
Why is that?
I am using Twitter bootstrap as well(extra info..)
Thank you
Add type="button" attribute to your button tag. Without it button works as submit.

Why does enter submit a form differently than clicking submit in IE 7?

In IE 7 the zip code search form on my page reacts differently when someone clicks submit vs pressing enter. It works correctly when sumbmit is clicked and incorrectly when enter is pressed.
http://getridofit.com
<form name="zip" action="<?php bloginfo('url'); ?>" method="get">
<input type="text" id="zipper" name="locations" size="5" maxlength="5" class="junk-input" onsubmit="return checkForm()" />
<input type="submit" value="" name="schedule" src="/wp-content/uploads/remove-my-junk.png" align="center" class="junk-button" style="background: #f67a3e url(/wp-content/uploads/remove-my-junk.png); border: none; width: 201px; height: 45px;"/>
</form>
The correct result for a zip search of 85718 looks like this: http://getridofit.com/l/85718/?schedule
but pressing enter produces a result like this: http://getridofit.com/l/85718/
Because the button wasnt clicked in order to submit the form. If you dont click the button then the input for #name[schedule] isnt sent. However if that button input has focus when enter is pressed i think it will send it along properly... You might jsut want to make schedule a hidden input.
It looks like you are checking for the presence of the submit button variable (schedule) in the URL bar. The submit button variable is only supposed to be submitted when the user physically clicks the the submit button. However, I can't reproduce the problem in Safari, so it may also depend on what your JavaScript is doing when the form is submitted.

How do I keep track of when what is the text entered in the form when the user navigates away from the page?

I have a piece of code like this.
<form method="get" action="{$self}" name="addcommentform">
<textarea title="{$enterComment}" name="comment" class="commentarea" </textarea>
<input class="Button" type="submit" value="{$postComment}" />
</form>
How do I keep track of when what is the text entered in the form's textarea when the user navigates away from the page? I want to prompt the user with a warning message so he/she doesn't lose the text.
Thanks.
You could use the javascript/jquery blur event, and if the user hasn't clicked the desired button have it display the form values. This might help JQuery Blur Validation Problem
Stu
Take a look at this Javascript code snippet:
http://www.boutell.com/newfaq/creating/disableclose.html
This takes advantage of the window's onbeforeunload event which fires when the user is about to leave the page.