You are here: Re: Text in textfield « HTML « IT news, forums, messages
Re: Text in textfield

Posted by Willy on 11/15/06 18:41

"Toby Inkster" <usenet200611@tobyinkster.co.uk> schreef in bericht
news:9q5r24-d46.ln1@ophelia.g5n.co.uk...
> Toby Inkster wrote:
> > Willy wrote:
> >
> >> <input name=userInput type=text value="something">
> >> Could value'something' ibe put in a variable via avascript?
> >
> > <form name=theForm>
> > <input name=userInput type=text value="">
> > </form>
> > <script type="text/javascript">
> > var myInput = document.forms["theForm"].elements["userInput"];
> > myInput.value = "something";
> > </script>
>
> Sorry -- I think I misread your question. My example above uses Javascript
> to put something into a form field. It seems you want to read it *out*.
>
> Here you have two options, depending on what you want to read. Say you
> have '<input value="something">' but the visitor then types into the form
> field 'something else'. Do you want to retrieve the original value
> 'something', or the new value 'something else'?
>
> If you want to retrieve 'something else' (which most people would probably
> want), then:
>
> <form name=theForm>
> <input name=userInput type=text value="something">
> </form>
> <script type="text/javascript">
> var myInput = document.forms["theForm"].elements["userInput"];
> var WhatIWant = myInput.value;
> // now the variable 'WhatIWant' has what you want.
> </script>
>
> If you want to retrieve the original value ('something') then you need
> 'myInput.defaultValue' instead of 'myInput.value'.
>
> --
> Toby A Inkster BSc (Hons) ARCS
> Contact Me ~ http://tobyinkster.co.uk/contact
>

It is as you guessed the value 'something else' that I wanted to retrieve.
My regards and thank you for your help
Willy

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация