| Author |
form name as a value of textbox.
|
Jigar Naik
Ranch Hand
Joined: Dec 12, 2006
Posts: 744
|
|
I want to set a value of textbox my form name which i can see in URL. e.g if my URL is this : http://localhost:8080/Tools/jsp/ContactDetails.jsp than he value of text box should be "ContactDetails.jsp" How do i achieve that... anybody any idea ???
|
Jigar Naik
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15357
|
|
Why are you not setting this value on the server when the page is rendered? Than you would not need JavaScript If for some strange reason you want to use JavaScript Eric
|
 |
Jigar Naik
Ranch Hand
Joined: Dec 12, 2006
Posts: 744
|
|
I tried your code : <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <script> window.&o&n&l&o&a&d = function(){ alert("Here"); var url = document.location.href var dirs = url.split("/"); var page = dirs[dirs.length-1]; [B]Line 12if(indexOf("?")>-1)page = page.split("?")[0]; if(indexOf("#")>-1)page = page.split("#")[0]; document.form1.text2.value = page; } </script> </head> <body> <form action="" name="form1"> <input type="text" name="text1"><br> <input type="text" name="text2"><br> <input type="text" name="text3"><br> <input type="submit" name="submit"> </form> </body> </html>[/B] but it is giving error object required at line no 12
|
 |
Jigar Naik
Ranch Hand
Joined: Dec 12, 2006
Posts: 744
|
|
i got it... thanks a lot.
|
 |
 |
|
|
subject: form name as a value of textbox.
|
|
|