Click here to Skip to main content
15,889,909 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
I have the following code that is supposed to collect a value by HREF clicks.
Each time I click a number it is to append it to the contents of the text field "number". When I click submit it goes to a new page that evaluates the content of "number". It seems to work fine in my editor (HTML-Kit) when I click preview and "number" populates as expected but it does not work in my browser. The text field stays empty. What seems to be the problem here?

<FORM ACTION="showcontent.htm" METHOD="post">
<input type="text" name="number" value="">
<TABLE BORDER="1">
    <TR>
        <TD WIDTH="20" ALIGN="center"><A HREF="#" onclick="number.value=number.value + '1';">1</A></TD>
        <TD WIDTH="20" ALIGN="center"><A HREF="#" onclick="number.value=number.value + '2';">2</A></TD>
        <TD WIDTH="20" ALIGN="center"><A HREF="#" onclick="number.value=number.value + '3';">3</A></TD>
    </TR>
    <TR>
        <TD WIDTH="20" ALIGN="center"><A HREF="#" onclick="number.value=number.value + '4';">4</A></TD>
        <TD WIDTH="20" ALIGN="center"><A HREF="#" onclick="number.value=number.value + '5';">5</A></TD>
        <TD WIDTH="20" ALIGN="center"><A HREF="#" onclick="number.value=number.value + '6';">6</A></TD>
    </TR>
    <TR>
        <TD WIDTH="20" ALIGN="center"><A HREF="#" onclick="number.value=number.value + '7';">7</A></TD>
        <TD WIDTH="20" ALIGN="center"><A HREF="#" onclick="number.value=number.value + '8';">8</A></TD>
        <TD WIDTH="20" ALIGN="center"><A HREF="#" onclick="number.value=number.value + '9';">9</A></TD>
    </TR>
    <TR>
        <TD WIDTH="20" ALIGN="center"><A HREF="#" onclick="number.value=number.value + ',';">,</A></TD>
        <TD WIDTH="20" ALIGN="center"><A HREF="#" onclick="number.value=number.value + '0';">0</A></TD>
        <TD WIDTH="20" ALIGN="center"><A HREF="#" onclick="number.value=number.value + '.';">.</A></TD>
    </TR>
</TABLE><BR />
<BUTTON TYPE="submit">Show result</BUTTON><BR /><BR />


What I have tried:

New code
Posted
Updated 16-Feb-17 16:46pm
v5
Comments
[no name] 15-Feb-17 15:50pm    
"Question removed for lack of useful response", and you waited less than one whole day before removing your question? Why just remove the text and not delete the whole thing if you are so impatient?
Kosimek 15-Feb-17 18:22pm    
@NotPoliticallyCorrect Because I received an email from the CodeProject stating:
"Your answer 'Populating an input field with multiple clicks in javascript' has been reported by Richard Deeming, Karthik Bangalore, NotPolitcallyCorrect and has been closed, with the reason being given as This post is spam, abusive or otherwise inappropriate."

There seems to be little point in keeping, what I considered a perfectly legitimate question, when some, including you, for some reason deemed it to be "spam, abusive or otherwise inappropriate"

The fact that you would even question my decision to remove the question, given that you are one of the people who deemed it so, is a mystery to me.

In addition, the email stated "Your article [...] will not be available in lists" which I can logically assume to mean that it cannot be found and therefore will not spur anyone else to actually offer a solution.
[no name] 15-Feb-17 20:53pm    
"including you", yes I reported your "question", so what? Go re-read your not-a-question and see if you can see what the rest of us saw.

"I considered a perfectly legitimate question", I am sure you thought so. In fact it wasn't a question at all. It was a request of us, the unpaid volunteers on the internet, to write some code for you. We are not here to work for you.

"is a mystery to me", and why is this a mystery to you? Do you still see the not-a-question here? Does this posting say that it has been closed? Why didn't you just delete it? That would certainly show us.

Kosimek 16-Feb-17 19:29pm    
For someone who is not only unprepared to even suggest a solution to my question that seems to consist of one line of code (see updated post), you certainly seem willing to spend a inordinate amount of your time responding to my post in the negative.
If this were a language website and someone asked help in translating a single paragraph into German, Dutch or whatever languages I happen to speak, I would not have a problem doing so to help out. I certainly would not rate the question as spam, abusive or inappropriate, because it is none of those, nor would I suggest to have him take a course to learn the language in question which would be absurd.

At least ppolymorphe, the first person to respond, provided some helpful links although they basically boil down to the latter, go learn javascript.

It's not like I asked anyone here to write me an app, so may I suggest that next time you come across a post like mine, rather than reporting it as spam, abusive or inappropriate and getting the question removed from the list so nobody else will see it, you just move on and leave it to others to respond in a more helpful manner. And please, save your time and try not to respond again.

Quote:
Found nothing that does exactly what I need and the javascript code that might do something similar to it, I do not understand enough to be able to modify for my purposes.

As programmer, your job is to create algorithms that solve specific problems. Creating an algorithm is basically finding the maths and make necessary adaptation to fit your actual problem.
I guess you need to JavaScript properly and extensively.
JavaScript Tutorial[^]
JavaScript Events[^]
Excellent tutorial site:
W3Schools Online Web Tutorials[^]
Quote:
:-) @ppolymorphe Thanks for going out of your way to not provide useful help.

If you look at the links, the 1 about events is what you need to launch JS code when you click on a matrix cell.
The piece of code you show is not html or JS, I have only a vague idea of what can be the result. Showing the html result won't gave hurt.
 
Share this answer
 
v3
That is an unusual piece of HTML look-a-like, for once, it is all upper case, where did you get it from? Did you write it yourself? Where did you learn to write such HTML? Whoever or wherever you learn it from, forget them altogether. Instead, learn from the genuine W3Schools Online Web Tutorials[^]. Start from HTML, CSS, and then JavaScript. Code Project has excellent articles at Learn HTML5 and CSS3[^] too.
 
Share this answer
 
Comments
Kosimek 17-Feb-17 1:26am    
Peter, that is an unusual piece of English.
Perhaps, if you have nothing to contribute, you might go troll somewhere else. Does your mother know you visit adult websites?
Peter Leow 17-Feb-17 1:39am    
That shows the quality of your upbringing and it is reported as abusive.
Kosimek 17-Feb-17 11:10am    
Upbringing? Seriously? Insulting people invites a like response. Did I miss your solution to my question in your post? Oh, no, there was none, it was just an entire rant dishing my coding style.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900