What Does It Mean When The Form Action Attribute Is "#" (Number/Pound Symbol/Sign/Character)

What does it mean when the form action attribute is # (number/pound symbol/sign/character)?

The meaning of # as a URL reference (whether as action or formaction attribute value or otherwise) is a reference to the start of the current base document. The base document is the current document, unless a <base href=...> tag has been set.

What happens depends on the situation. Typically, the browser requests for the page again with a query part in the URL (and the page is loaded again, which may imply that client-side scripts are run), but if the same query had been used earlier, the browser probably uses its cache. Moreover, as the start of the document is referred to, focus on any form element is lost and the page may scroll backwards.

So although # is fairly common in some coding styles, it is not reliable; its purpose is better achieved using client-side event handlers.

The formaction attribute has a meaning only for submit buttons. A text input element does not constitute a submit button, even though it may trigger form submission, so here the attribute is ignored.

What is <form action=#>?

An action of "#" indicates that the form stays on the same page, simply suffixing the URL with a #.

what does the hash mean in action=# in html form tag

'#' submits form action url to itself(your page url where the form resides).
Mostly used for dummy purposes and same page form submissions, although there are better techniques out there.
Have a look at this answer

what does it mean form action attribute

What does Action=# mean?

Action="#" is basically the html equivalent of Post to self. # is technically an anchor so if you click on a link that is just "#" it does nothing.

Browser should interpret any Action="#" as Action="THE_HOSTNAME/PAGE"

Its designed to get around W3C Validation a times since Action="" is considered invalid, since all attributes must have values, this ensures a value is available for the attribute.

Why I am getting GET vars in a POST form?

Using action="#", you will submit the form to the current URL. Your GET vars are part of this URL so that is why you're getting them again.

More infos on this question.

IE munging pound (£) symbol

accept-charset="UTF-8"

Does not do what you think it does (or the standard says it does) in IE. Instead, IE uses the value (‘UTF-8’) as an alternative list of encodings for if a field can't be encoded using the usual default encoding (which is the same as the page's own encoding).

So if you add this attribute and your page isn't already in UTF-8, you can be getting characters submitted as either the page encoding or UTF-8, and there is no way for your form-submission-reading script to know!

For this reason you should never use accept-charset; instead you should always ensure that the page containing the form is correctly served as “Content-Type: text/html;charset=utf-8” (by HTTP header and/or <meta>).

In fact if I put the € symbol with a £ symbol it also works fine.

Yes, that's because ‘€’ cannot be encoded in the page's default encoding (presumably ISO-8859-1). So IE resorts to sending the field encoded as UTF-8, which is what you wanted all along.

What is it when a link has a pound # sign in it

It's a "fragment" or "named anchor". You can you use to link to part of a document. Typically when you link to a page, the browser opens it up at the top of the page. But you link to a section half-way down, you can use the fragment to link to that heading (or whatever).

If there is no <a name="whatever"/> tag within the page, then the browser will just link to the top of the page. If the fragment is empty, then it will also just link to the top of the page.

For a fragment only <a href="#">Link name</a>, then that's just a link to the top of the current page.

You often see that kind of link used in conjuction with javascript. Standards compliant HTML requires a href attribute, but if you're planning to handle the request with javascript then "#" serves as a reasonable place holder.

Display a pound / currency symbol in a Django select input

If I have understand your question correctly, the problem is that £ is automatically escaped by the form library and therefore displayed as £ to the user and not as £.

You can probably solve the problem by telling django that the HTML code is safe and shouldn't be escaped (might be a XSS security hole):

from django.utils.safestring import mark_safe
choices = (mark_safe('£ 2,500'), ...)

Alternatively you can also avoid the usage of escape sequences by typing in the characters directly (those entities aren't part of current HTML specifications anyway, you should simply use unicode instead):

# -*- coding: utf-8 -*-
choices = (u'£ 2,500', ...)

The comment with the encoding must be the first line of the current file, telling the interpreter that you are using unicode encoding in the source file.

IE munging pound (£) symbol

accept-charset="UTF-8"

Does not do what you think it does (or the standard says it does) in IE. Instead, IE uses the value (‘UTF-8’) as an alternative list of encodings for if a field can't be encoded using the usual default encoding (which is the same as the page's own encoding).

So if you add this attribute and your page isn't already in UTF-8, you can be getting characters submitted as either the page encoding or UTF-8, and there is no way for your form-submission-reading script to know!

For this reason you should never use accept-charset; instead you should always ensure that the page containing the form is correctly served as “Content-Type: text/html;charset=utf-8” (by HTTP header and/or <meta>).

In fact if I put the € symbol with a £ symbol it also works fine.

Yes, that's because ‘€’ cannot be encoded in the page's default encoding (presumably ISO-8859-1). So IE resorts to sending the field encoded as UTF-8, which is what you wanted all along.

Pass the value of check checkbox and display the first value on the array

I tried that code,set id="submit" at the submit button of the modal form and id="test_modal[]" at checkboxes,I used some functions of jquery I set at header the <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>

 <script type="text/javascript">
$(document).ready(function(){
$("#submit").click(function(e) {

// var checked = [];
i=0;
temp=""
$("input[name='test_modal[]']:checked").each(function ()
{ temp=$(this).val();
i++;
// checked.push($(this).val());
});
if (i==1)
$("#test").val(temp);
else if (i>1)
$("#test").val('multiple');
$("#modal").fadeOut();
// alert($("#do").val())
e.preventDefault();
});
});</script>


Related Topics



Leave a reply



Submit