[Javascript] Dynamically generate link from text being typed in textbox?

David Yee dyee at AMSResponse.com
Thu Jan 17 17:48:38 CST 2002


Got- seems to work.  Thanks!

> -----Original Message-----
> From: Hassan Schroeder [mailto:hassan at webtuitive.com]
> Sent: Thursday, January 17, 2002 3:43 PM
> To: javascript at LaTech.edu
> Subject: Re: [Javascript] Dynamically generate link from text being
> typed in textbox?
> 
> 
> David Yee wrote:
> > 
> > Hassan- I tried the code but when I click on the the link I 
> stay on the same
> > page.  The default value for foo works, however.  Maybe I'm 
> doing something
> > wrong?
> 
> This only sets the var 'foo' if the text field loses focus first;
> trying entering the URL, tabbing out of it, and then clicking the
> link. 
> 
> If that's problematic - there's nothing more for the user to enter
> and they're likely to immediately mouse to the link - you'd want to
> collect the value of the text box (and any other form values) with 
> the link's onclick(). 
> 
> > > <script type="text/javascript">
> > >
> > >       var foo = "http://some.default.url/";
> > >
> > >       function qOpen()
> > >       {
> > >               window.location = foo;
> > >       }
> > >
> > > </script>
> > >
> > > <a href="javascript://;" onclick="qOpen();return 
> false;">a link</a>
> > >
> > > <form method="post" action="/whatever/process.cgi">
> > >
> > >       <input type="text" onblur="foo=this.value;" />
> > >       <input type="submit" value=" submit " />
> > > </form>
> 
> -- 
> H*
> Hassan Schroeder ----------------------------- hassan at webtuitive.com 
> Webtuitive Design ===  (+1) 408-938-0567   === http://webtuitive.com
> 
>     -- creating dynamic Web sites and applications since 1994 --
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
> 



More information about the Javascript mailing list