问题描述:

so-far I have tried everything. My code is below but when I run it nothing seems to happen, nor do I get any error messages. I'm working with Toad for oracle, so I'm literally hard-coding

-- form field and button --

http.p ('<input type="form" method="post" name="idstu" id="idstu" placeholder="e.g. 000123456">');

htp.br;

htp.p (' <input type="submit" onclick="confirmMsg()" value="Submit">');

-- javascript --

http.p ('<script type="text/javascript">

function confirmMsg() {

var field1 = document.getElementById("idstu").value;

alert(field1 "has been unsuspended");

}');

网友答案:

Below the working answer.

<html>
<head>
<script type="text/javascript">
                    function confirmMsg() {
                    var field1 = document.getElementById("idstu").value;
                    alert(field1+"has been unsuspended");
                    }
</script>
</head>
<body>
<input type="form" method="post" name="idstu" id="idstu" placeholder="e.g. 000123456">
<input type="submit" onclick="confirmMsg()" value="Submit">
</body>
</html>
网友答案:

Please try removing type=submit in <input> tag.

网友答案:

your code would be causing error .

<input type="form" method="post" name="idstu" id="idstu" placeholder="e.g. 000123456"> 

it should be type='text'.And alert should be like :

alert(field1+"has been unsuspended");
}
</script> <!--must have the habit to close each tag -->
网友答案:

i've got it to work. first of all as @liju mentioned i didn't close the script tag as i have thousands of lines(stupid mistake). 2nd i played around with the code again and changed the input types of both field and button. now i do get the alert message. Thanks everyone . --working code below. --

htp.p ('<input type="text" method="post" name="idstu" id="idstu" placeholder="e.g. 000123456">');
            htp.br;
            htp.p (' <input type="button" onclick="confirmMsg()" value="Submit">');

htp.p ('<script type="text/javascript">
                    function confirmMsg() {
                    var field1 = document.getElementById("idstu").value;
                    alert(field1+"has been unsuspended");
                    }   
                    </script>');
相关阅读:
Top