PDA

View Full Version : How to pass NULL values to the elements the user left blank.


krnaveen
06-28-2002, 08:57 AM
Hi! Friends,
Help me out, Pls.
Am having a form containing ten elements which is used to insert values in the database. The user has the option to enter a value or leave it blank, for any of the element. How do I pass NULL values to the element which the user has left blank ? Am trying to use Javascript but not yet successfull. The query does not execute without passing NULL values for the fields left blank. If all the fields have the value then its working perfectly fine. Am using ASP for server side programming and HTML for Client-side.
Urgent.
-Navin.

joh6nn
06-28-2002, 09:28 AM
http://www.codingforums.com/showthread.php?s=&threadid=727

adios
06-28-2002, 08:29 PM
<html>
<head>
<script type="text/javascript">

function setNULLS(f) {
var currEl, e = 0;
while (currEl = f.elements[e++])
if (currEl.type == 'text' && !currEl.value) currEl.value = 'NULL';
}

</script>
</head>

<body>
<form onsubmit="setNULLS(this)">
<input name="t1" type="text"><br>
<input name="t2" type="text"><br>
<input name="t3" type="text"><br>
<input name="t4" type="text"><br>
<input name="t5" type="text"><br><br>
<input type="submit" value="DONE">
</form>
</body>
</html>