/    Sign up×
Community /Pin to ProfileBookmark

A strange problem/situation with a form on my site

In this post I’ll write about a confusion regarding some particular form on my website. As a result of things mentioned in [URL=http://forums.digitalpoint.com/showpost.php?p=5101556&postcount=34]this post of mine[/URL] in some thread on DP forums, I checked the code of some particular form on my website: [URL=http://tadejpersic.50webs.com/index.html]http://tadejpersic.50webs.com/index.html[/URL] (please visit it to actually see what I am talking about)

I am talking about that line/row of buttons, while the problematic one is the first one, which uses an external .js file and which function is to bookmark the current page (the other two buttons with [I]<input type=”image”[/I] in this line/row are to open a search and contact pages); here below is the original code of the “bookmark page” form:

[CODE]<form action=”#”>
<input type=”button” value=”Bookmark us!” onclick=”bookmark(‘http://javascript.internet.com/’,’JavaScript Source’)”>
</form>[/CODE]

Well, and then I checked the code as it is currently on my website, and I noticed that (not sure why/when, but as you can see, this is the only way to show them all in one line; please see below) I changed it so that it looks like (compare to the original “bookmark page” form code above) I forgot to close it with the “[I]</form>[/I]” ending tag. So here below is the code of the “bookmark page” form (and I also included the code of buttons that open search and contact pages) as it is on my website, and it surely works as it should, and the page is validated by the W3C checker:

[CODE]<form action=”#” /><input type=”image” src=”save.png” title=”bookmark page” onclick=”bookmark(‘index.html’,’Tadej Persic’s website | index’)” />&nbsp;<input type=”image” src=”search.png” title=”search site/web” onclick=”window.open(‘search.html’,’search’,’height=560,width=440′)” />&nbsp;<input type=”image” src=”contact.png” title=”contact me” onclick=”window.open(‘contact.html’,’contact’,’height=560,width=440′)” />[/CODE]

But if I change the code to remove the [I]” />[/I] part (i.e. to become [I]“>[/I]) and add the closing “[I]</form>[/I]” tag as you can see in the first example below, then the “bookmark page” button is placed in its own line above the line/row with the rest of the buttons. Here below are examples of the code of the “bookmark page” form (with the code of buttons that open search and contact pages removed for you to easily see the change); in the first example there’s the code as it is after I modified it (i.e. I changed the [I]” />[/I] part to become [I]“>[/I], and added the closing tag, as mentioned above), and as it was/and still is originally on my website:

[CODE]<form action=”#”><input type=”image” src=”save.png” title=”bookmark page” onclick=”bookmark(‘index.html’,’Tadej Persic’s website | index’)” /></form>&nbsp;…[/CODE]

[CODE]<form action=”#” /><input type=”image” src=”save.png” title=”bookmark page” onclick=”bookmark(‘index.html’,’Tadej Persic’s website | index’)” />&nbsp;…[/CODE]

Therefore I am curious: is the form of the code like I modified it afterwards correct, or should I close it with the ending tag “[I]</form>[/I]” as it is in the original code (it’s an example from some tutorial I guess)of the mentioned form??!

tayiper

to post a comment
HTML

7 Comments(s)

Copy linkTweet thisAlerts:
@WebJoelNov 05.2007 — You need to close "form" with a proper closure tag, because:
<form action="#"[B][SIZE="4"]>[/SIZE][/B]<input type="image" src="save.png" title="bookmark page" onclick="bookmark('index.html','Tadej Persic's website | index')" />...[/QUOTE]

Currently, you only properly-closed "<input...." with "[B] /[/B]>"

There will be a missing-expected "</form>" warning, as written above.

[B]<form action="#" />[/B] is wrong, because it 'closes' "<form>" before input. You want [B]<form> <input ... /> [U]</form>[/U][/B] ?
Copy linkTweet thisAlerts:
@tayiperauthorNov 05.2007 — You need to close "form" with a proper closure tag, because:


Currently, you only properly-closed "<input...." with "[B] /[/B]>"

There will be a missing-expected "</form>" warning, as written above.

[B]<form action="#" />[/B] is wrong, because it 'closes' "<form>" before input. You want [B]<form> <input ... /> [U]</form>[/U][/B] ?[/QUOTE]


Thanks much [B]WebJoel[/B], so then it is as I thought (i.e. that the right form is as it's in original example from that tutorial), but anyway, the strange thing is that it works correctly even now (i.e. with from not closed) as it is ...


And do you have any idea on how to align this "bookmark page" (after I fix it of course, because now they are aligned, but the form is as mentioned not propery closed) from with the rest of the buttons??!


tayiper
Copy linkTweet thisAlerts:
@tayiperauthorNov 06.2007 — Oh and one more question: what about other [I]<input type="image"[/I] do they all require on the beginning??!


tayiper
Copy linkTweet thisAlerts:
@tayiperauthorNov 06.2007 — Oh and one more question: what about other [I]<input type="image"[/I] do they all require on the beginning??![/QUOTE]

Sorry, the text should read: ... do they all require [I]<form action="#">[/I] in the beginning??!


tayiper
Copy linkTweet thisAlerts:
@WebJoelNov 06.2007 — Sorry, the text should read: ... do they all require [I]<form action="#">[/I] in the beginning??!


tayiper[/QUOTE]

If some action (like a submit button to click), they do require [I]action="#"[/I] and a filename URL is the "#"

I found this:

http://www.w3schools.com/html/html_forms.asp
Copy linkTweet thisAlerts:
@tayiperauthorNov 10.2007 — If some action (like a submit button to click), they do require [I]action="#"[/I] and a filename URL is the "#"[/QUOTE]

Thanks much for the additional explanation... I only have one question left: what's the difference between, or in other words, is it possible to use [I][B]<a href=""[/B][/I] instead of [I][B]<a href="#"[/B][/I] (and similarly for the form [I][B]<form action="">[/B][/I] instead of [I][B]<form action="#">[/B][/I]), same as I do to open such popup window below under the "Copyright notice" for the [URL=http://creativecommons.org/licenses/disclaimer-popup?lang=en]disc[/URL] link where it says:

The website is licensed by Creative Commons ([URL=http://creativecommons.org/licenses/by-nc-nd/2.5/deed.en]deed[/URL]/[URL=http://creativecommons.org/licenses/by-nc-nd/2.5/legalcode]code[/URL]/[URL=http://creativecommons.org/licenses/disclaimer-popup?lang=en]disc[/URL]) license. Some Rights Reserved.[/QUOTE]


  • 1. Namely, I've found out that indeed don't need to use form (nor [I]<input type="...[/I] of course) for the other two mentioned elements (i.e. for buttons that open the "search" and "contact" pages, beside the one that bookmarks the page, which does require it) in the line/row of the buttons!! Actually, I am not sure why I did use them in the first place.


  • Here's the old code:

    [CODE]<input type="image" src="search.png" title="search site/web" onclick="window.open('search.html','search','height=560,width=440')" />

    <input type="image" src="contact.png" title="contact me" onclick="window.open('contact.html','contact','height=560,width=440')" />[/CODE]


    And here the new one:

    [CODE]<a href="#" onclick="window.open('search.html','search','height=560,width=440')"><img class="button" src="search.png" alt="search site/web" title="search site/web" /></a>

    <a href="#" onclick="window.open('contact.html','contact','height=560,width=440')"><img class="button" src="contact.png" alt="contact me" title="contact me" /></a>[/CODE]



  • 2. And secondly regarding the other problem that I had (i.e. that there is not possible to align this "bookmark page" button that uses a form with the rest of the buttons), I simply moved this particlar button elsewhere, namely under the title (i.e. [I]<h1>[/I] headline) of the respective page.



  • But anyway, if anyone does know for a way to do it as it was before (i.e. all the buttons in the same line/aligned to the same row), I would be glad to hear it.


    P.S. - Finally, just a note on one strange thing. You see, it's that the page in question strangely did validate even before (with one form not propery closed, and with two [I]<input type="...[/I] without form "around them"); see for instance the W3C Markup Validator results here: [URL=http://validator.w3.org/check?uri=http%3A%2F%2Ftadejpersic.50webs.com%2Fsample%2Findex-old.html&charset=%28detect+automatically%29&doctype=Inline&group=0][Valid] Markup Validation of .../sample/index-old.html[/URL] for the sample file of the: [URL=http://tadejpersic.50webs.com/sample/index-old.html]index-old.html[/URL] page that still had the mentioned things coded in a wrong manner (and btw. it also still had an old layout)


    tayiper
    Copy linkTweet thisAlerts:
    @WebJoelNov 10.2007 — <a href="#"> simply means "self", and is 'skipped' as being a warning if validated. The absence of the "#" throws a validation warning. Nothing more complicated than simply this is how I write it when a link is not provided (or I need to post-up and do not want to divulge the client's URL to the web, else it shows up here in WD archive base in a few weeks on Google SEARCH, usually to the client's dismay.. ? ).

    Another way is "<a href="#nogo">" which means of course, you 'no go' anywhere when clicked.

    Others include alt="#", title="#", etc. These would validate, but for Accessibility, should have actual text.

    I don't think that [B]action="#"[/B] would serve the same purpose, as some action is required and "self" or "nogo" is not a viable option. Not sure... haven't done alot with "<form>"s myself other than copy&paste existing ones.
    ×

    Success!

    Help @tayiper spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 6.17,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @nearjob,
    tipped: article
    amount: 1000 SATS,

    tipper: @meenaratha,
    tipped: article
    amount: 1000 SATS,

    tipper: @meenaratha,
    tipped: article
    amount: 1000 SATS,
    )...