I have a quick question about disabling an onclick after the action has been processed. This is for a form which can be viewed back at a later time. The problem is that when you are in the view I do not want the onclick function to be run actually I want the radio button to stay selected from what was submitted.
<input type="radio" name="#str#" id="#str#" value="yes" onclick="valuechanged(this)"
<cfif len(#audit#) gt 0 and getsafetytype.weight eq colvalue>
checked="yes"
</cfif>
So the view command runs the if statement have having a value. I can not figure out how to make the onclik disable during the if statement without disabling it when a new form is being created. Any ideas would be great.
Related
I have a form within a repeating region that I would like to have two buttons on.
I currently have one button (an image) that submits the form and generates a preview of the record. I would like to add a second button to the same form that performs a different function. I have assigned different names and values to each of the image buttons but how do I retrieve that value and either do a corresponding response.redirect or perform an additional function?
I know in PHP you can use the $_GET["getvar"]; or $_post["getvar"]; but i am using classic asp.
Any help would be greatly appreciated!
example for you
<input type="hidden" name="PageAction" value="" />
<input type="image" name="button1" src="imgage1.jpg" onclick="this.form.PageAction.value='function1';this.form.submit();" />
<input type="image" name="button2" src="imgage2.jpg" onclick="this.form.PageAction.value='function2';this.form.submit();" />
then you can retrive the value of request("PageAction") to seperate diffrent actions,like:
if request("PageAction")="function1" then
call function1()
elseif request("PageAction")="function2" then
call function2()
end if
Request.QueryString("getvar") is the equivalent of $_get and Request.Form("getvar") is the equivalent of $_post.
Where getvar is the name of the button, it will return the value.
I was exploring the search box on the Apple website and noticed it doesn't have a input type="submit" to post the form, even when Javascript is disabled.
<form action="/search/" method="post" class="search" id="g-search">
<div class="sp-label">
<label for="sp-searchtext">Search</label>
<input type="text" name="q" id="sp-searchtext" accesskey="s">
</div>
</form>
Having never really explored it, I take it from this it means you can post a form without needing a submit button, it just relies on the user pressing the return key.
Two questions: 1) Is this compatible across all browsers? So in IE 7 will pressing return still work?; 2) Is there a way to do this in ASP.NET without using an asp:button? I will probably have it inside a placeholder (where I would conventionally use defaultButton to allow for multiple forms on the page) but if I can get rid of the button altogether then that's a plus.
yes of course it is possible to do it in anyway you want.
The simpler thing is to have an onclick event that calls a function that does the submit like this:
JQuery:
$('#id_of_form').submit()
javascript:
document.name_of_my_form.submit();
or
document.getElementById('id_of_my_form').submit();
so simple :)
*ASP.NET VB.NET 2010 ****
Hi,
KIndly help me with this, I have a list of Hyperlink. If I press radio button I want my cursor to focus on one of my hyperlink
I tried to used this but no luck
Dim sScript As String = "document.getElementById('" & hlnkQNo.ID & "').focus();"
'Page.RegisterStartupScript("controlFocus", sScript)
I also tried this but the same, the cursor was not focus on my link
ScriptManager1.SetFocus(hlnkQNo.ID).
Here is my example of what I want
Hyperlink1
Hyperlink2
Hyperlink3
Hyperlink3
Hyperlink4
if the use click the radio button i want to focus on Hyperlink4
Your question is difficult to understand, but generally if you want to focus an element you need to set an event handler on the radio button so that when it's clicked another element receives focus.
document.getElementById("myRadioButton").click = function(){
document.getElementById("Hyperlink1").focus();
};
If your code is being generated server side with VB.NET, then you're going to have to figure out exactly how the snippet above should be rendered.
just to provide an alternative, maybe you might want to consider using jquery to do those kind of things.
and as long as you put runat="server" on your control, you can still retrieve all the value or manipulate them on the server side.
link 1
link 2
link 3
link 4
<br />
<input type="radio" name="radio4" id="radio4" value="4" /> 4<br />
$(document).ready(function(){
$("#radio4").click(function(){
$("a:eq(3)").css('color','red');
$("a:eq(3)").focus();
});
});
I have a webpage, in that page I have a button. How can I refresh the page when clicking on that button?
<input type="button" value="Reload" onclick="window.location.reload(true);" />
However, if the page is created from a postback, you would need to use an asp:Button control instead, and let another postback refresh the page. You also have to make sure that the correct code is executed in the code behind to recreate the correct result.
are you using an
<asp:button />
tag?
If so the page should refresh when the button is clicked by default.
<form>
<input TYPE="submit" VALUE="Submit Information Now" />
</form>
SUBMIT is a TYPE attribute value to the INPUT element for FORMs. It specifies a button that, when activated, submits the information entered to a processing script. If there are multiple SUBMIT buttons in a form, only the one activated should be sent to the form processing script.
When you press button your page must refresh, only not refresh that controls which are in AJAX Update Panel
I am working on a ASP.NET MVC web site that has multiple submit buttons. i.e.
<input type="submit" name="SubmitButton" value="Reset" />
<input type="submit" name="SubmitButton" value="OK" />
<input type="submit" name="SubmitButton" value="Back" />
I need to allow users to quickly submitting the form by pressing the 'Enter' key. HTML standard seems to specify that the first submit button will be assumed if a user press the 'Enter' key. However, I need to make the 2nd button (i.e. the "OK") button the default button and for reasons I don't even want to talk about, changing the button order is not an option.
I googled around and I found this post about using Page.Form.DefaultButton in ASP.NET but this doesn't work with ASP.NET MVC.
I also tried the following javascript solution, while it works in Chrome but doesn't work in IE6
$('body').keypress(function(e) {
if (e.which === 13) {
$("input[value='OK']").trigger('click');
}
});
I can think of some really extreme solutions such as going through every single controls in the form an attach the above function to them. However, I don't think that's a very neat solution so I am wondering has anyone got a better solution?
First off, this is wrong:
<input type="submit" name="SubmitButton" value="Reset" />
<input type="submit" name="SubmitButton" value="OK" />
<input type="submit" name="SubmitButton" value="Back" />
All three of them are submit buttons. A reset is an input of type="reset". Get that sorted. Second of all, I've successfully implemented something like that, and it works on IE6. Try this:
function keypressHandler(e)
{
if(e.which == 13) {
e.preventDefault(); //stops default action: submitting form
$(this).blur();
$('#SubmitButton').focus().click();//give your submit an ID
}
}
$('#myForm').keypress(keypressHandler);
The focus() part makes the button appear to be pressed when the user presses enter. Quite nifty.
Use this.
$(function(){
$('input').keydown(function(e){
if (e.keyCode == 13) {
$("input[value='OK']").focus().click();
return false;
}
});
});
You should only have one submit button. The reset button should be type="reset" and the back button should probably be type="button" like this:
<input type="reset" name="ResetButton" value="Reset" />
<input type="submit" name="SubmitButton" value="OK" />
<input type="button" name="BackButton" value="Back" />
Then, Reset and OK will just work the way they are supposed to and you'll only need to handle the Back button click with Javascript.
Edit: The other option would be to place the Reset and Back submit buttons each in their own forms inside iframes. Then they would be ignored by the main form and wouldn't be default buttons. Also, this would allow you to point them to different server actions if needed and there wouldn't be any reliance on Javascript for the button actions.
HTML standard seems to specify that
the first submit button will be
assumed if a user press the 'Enter'
key.
No, the usage of the enter key isn't defined, it's a propritary extension that's been added under various interpretations. You will get different behavoir in different browsers (and it can become very dangerous when you start mixing in different cultural or UI conventions about left to right/right to left ordering of options).
If there is only 1 button on the form then all the mainstream browsers happen to follow the same behavior - they submit the form as if that button was pressed (a buttonName=buttonValue is included with the form data). Of course this doesn't mean the buttons onclick handler is going to fire - that behavoir is browser specific.
When there are several buttons it's a complete crap shoot. Some browsers decide that the first button (and the definition of first can vary - most use the first one mentioned in the Html tree, while others attempt to use screen position) was clicked and use it in the submission, while other browsers (notably some versions of IE) make the equally correct assumption that no specific button was pressed, and so don't include a buttonName=buttonValue (the rest of the form is submitted fine).
Since you use jquery, if you use hotkeys plugin, you can make a such approach:
$(document).bind('keydown', 'return', function (evt){
$.next("input[value='OK']").trigger("click");
return false;
});
Change button order in source but not visually (ie, use CSS to swap the buttons)?