Updating an embeded Web page

Hello All,

This is my first post in this forum.

I have the task of editing an existing web page from an embedded design, the web pages are identical to a normal except for the server side scripting is slightly different.

The problem I’m facing (and I’m not a web developer so please bear with me), is the existing page just had forms submitted with buttons but some things should not be submitted so easily as bad things can happen. I would like to have a submit button that calls a java script the asks if this is what they really want to do then depending upon that answer continue or throw away the request.
I have tried a few things already but can’t seem to get it to work. I tried using the java submit method but it never submitted anything.

Basically I’m asking what is the best way to approach this, is it a mixture of HTML and Java or pure java?
Not looking for a hand out here, I want to understand what it is I’m doing but a few examples would be helpful.

Btw The first part I’m working on is a group of 5 radio buttons with a submit button that calls a java script to confirm the request.

Thanks

The best way to handle this is to not rely on JavaScript for form submissions.

Ensure that the server knows how to handle and deal with bad form submissions, as well as good ones. Only once the server knows how to properly deal with things should you then use scripting to help improve the user experience, which mostly consists of showing error conditions without needing to submit, and preventing the form from being submitted when the form is not in a valid state.

Thanks for the reply,

I have no need to test for a valid state. Basically, I need the process to be in the stopped state before anything is accepted, this I know how to do. There is a setting on the page that allows a gate to be manual opened to 0%,25%,50%75%,100% ( the radio buttons) and on the first click I want to warn the user that this could flood their process so I need to intercept the submit button ask the question then act on the reply of yes or no. Further submits will not ask the question until the process starts up again. I just need to know how to ask the question on the button press and submit the radio button checked status to my server. Should I use java in the button to call a function that asks the question then either submits the request or throws it away or can this whole thing be done in java?

What happens when JavaScript is not available, or has been deliberately disabled? All of those scripted solutions are then guaranteed to fail.

Please do not rely on JavaScript for business logic. Always first ensure that the server knows how to handle things first.

I understand your concern but if Java is not available or has been disabled then nothing can take place from the web page and everything is safe, this is not an emergency stop button. No lives are at risk. I just want to catch an accidental pressing of the submit button. Now we also have Ethernet mod-bus to do these changes as well. I just want to have the convenience of things on the web page along with most other settings.

Please don’t say Java if you mean JavaScript. The language called JavaScript was initially LiveScript, and was inspired from Self and Scheme and a few other languages.
When LiveScript was being added to the Netscape web browser, it was for political reasons renamed to JavaScript.
Then Microsoft wanted to implement something similar, so they created JScript.

Both JavaScript and JScript are supposed to be standardised under a standard called ECMAScript, but Microsoft seem to have stopped at ECMAScript Edition 3, whereas JavaScript has contined to be supported on most other web browsers up to the current ECMAScript Edition 5.1

Java is not JavaScript, and JavaScript is not Java. Java is used to creating plugins on the page, similar to Flash apps. JavaScript and Java are both completely different languages from each other, are used very differently, and can not be used interchangeably.

If you need help with Java, we cannot provide that sort of help here.

Sorry like I said I’m an embedded developer, this is mostly new to me. I need help with the JavaScript on my web page.

The best way to validate a form before it’s submitted is to override the onsubmit event of the form.

In your case though, you want to do something when a radio button is clicked, the best way of doing that is to monitor the onclick event of what the radio buttons are contained with.

You were also saying:

I am curious as to how the web page will know that the process (what process) starts up again.

I was actually thinking of submit button for the radio buttons just to keep the look of the page uniform.

Well I hadn’t gotten there yet, but I was thinking the server could pass a variable to the page, say a boolean. ( the page reloads every 10 sec). Future designs will have live data using AJAX.

Then that’s even easier, just override the submit event of the form itself.

For example:


...
<body>
<form id="openGate">
    ...
    <p><input type="submit" value="Submit"></p>
</form>
...
<script type="text/javascript" src="script.js></script>
</body>
</html>


document.getElementById('openGate').onsubmit = function () {
    return window.prompt('Are you sure?');
};