
- Forum
- Programming Talk
- ASP
- JavaScript question
JavaScript question
This is a discussion on JavaScript question within the ASP forums, part of the Programming Talk category; Hi I have developed an ASP page with few check boxes & one text box. When user ticks one check ...
-
JavaScript question
Hi
I have developed an ASP page with few check boxes & one text box.
When user ticks one check box (i.e. Other) then it should allow user to type something on text box otherwise it should lock text box. Is it possible using Java Script? How?
OR
When user ticks \'Other\' check box, text box should be visible otherwise it should be invisible. is it possible using JavaScript? How?
Thanks in advance
Pradeep
-
07-06-2004, 08:41 AM #2sanereddy Guest
Re:JavaScript question
pradeep, Just take a look at the java script ebooks in our EFS Directory, we have lots of them. Here is the basic idea how you can use the java script.
The example below is a simple search box form consisting of a text box named \"term\" and a button named \"Search\". The onClick event of the Search button passes the form as an argument to a function named \"Validate\". The Validate function will check the form and, if its okay, submit it to the server.
<form name=\"search\" method=\"post\">
<input name=\"term\" size=15 maxlength=50>
<input type=\"button\" value=\"Search\" onClick=\"Validate(this.form);\">
</form>
The form tag allows you to submit the form using either the POST method or the GET method. The GET method causes the browser to append all data from the submitted form to the URL. We don\'t want this because the user can then edit the form information directly in the browsers address bar, bypassing the Validate function entirely.
The POST method causes the browser to send all the data from the submitted form in the HTTP header where it is not visible to the user. In this article, I\'m not going to go into detail about what to do at the server end for processing the form. But, if for example you were using Active Server Pages (ASP), you would use the Request.QueryString(\"term\"
function to retrieve the form data with the GET method.
You would use the Request.Form(\"term\"
function to retrieve the form data with the POST method. So the user can play with the address bar URL all they want and your server side application will ignore it.
Below is code for the most basic Validate function. You would place this code in the head section of the Web page containing the form. It only checks for the case of an empty term text box. If the text box is empty it displays a message in a dialog box to the user. If the term text box is not empty, it submits the form to the server.
<script language=\"JavaScript\">
function Validate(form)
{
if(form.term.value == \"\"
{
alert(\"Enter a search term\"
;
}
else
{
form.submit();
}
}
</script>
hope this helps.
Thanks,
sanereddy
-
Re:JavaScript question
Thanks sanereddy for helping...
I got the solution and posting it here.
<html>
<head>
<script>
function disaT(c,f){
if(c.checked){f.txt1.disabled=false}
else{f.txt1.disabled=true}
}
function showT(c,f){
if(c.checked){f.txt2.style.visibility=\"visible\"}
else{f.txt2.style.visibility=\"hidden\"}
}
</script>
</head>
<body>
<form>
<input type=\"checkbox\" onclick=\"disaT(this,this.form)\"><input name=\"txt1\" type=\"text\" disabled=\"true\"><br>
<br>
<input type=\"checkbox\"onclick=\"showT(this,this.form)\"><input name=\"txt2\" type=\"text\" style=\"visibility:hidden\">
</form>
</body>
</html>
-
Sponsored Ads

Reply With Quote





