• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

form name as a value of textbox.

 
Ranch Hand
Posts: 763
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ???
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 763
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 763
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i got it... thanks a lot.
 
reply
    Bookmark Topic Watch Topic
  • New Topic