User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the HTML and CSS section within the Web Development category of DaniWeb, a massive community of 392,072 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,175 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our HTML and CSS advertiser: Lunarpages Web Hosting
Views: 6228 | Replies: 14
Reply
Join Date: Mar 2006
Location: Philippines
Posts: 112
Reputation: Covinus is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
Covinus's Avatar
Covinus Covinus is offline Offline
Junior Poster

getting the text field value

  #1  
Jul 31st, 2006
how do I get The value I have entered in a textfield after submitting it. i need to process it using java

thanks
if you cant hit 2 birds with one stone try hitting just one or you will end up with nothing at all
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Dec 2004
Posts: 1,589
Reputation: tgreer is an unknown quantity at this point 
Rep Power: 7
Solved Threads: 34
Colleague
tgreer tgreer is offline Offline
Made Her Cry

Re: getting the text field value

  #2  
Jul 31st, 2006
Get the value AFTER you submit it? That would be a server-side question. Since you mention Java, I suggest you ask in the Java forum. All values are packaged in the RESPONSE object, but that object is exposed in different ways in different languages.
Reply With Quote  
Join Date: Mar 2006
Location: Philippines
Posts: 112
Reputation: Covinus is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
Covinus's Avatar
Covinus Covinus is offline Offline
Junior Poster

Re: getting the text field value

  #3  
Jul 31st, 2006
opps i i want to get it using javascript.

hehehe
if you cant hit 2 birds with one stone try hitting just one or you will end up with nothing at all
Reply With Quote  
Join Date: Feb 2005
Location: Braintree, UK
Posts: 1,164
Reputation: hollystyles will become famous soon enough hollystyles will become famous soon enough 
Rep Power: 7
Solved Threads: 58
hollystyles's Avatar
hollystyles hollystyles is offline Offline
Veteran Poster

Re: getting the text field value

  #4  
Aug 1st, 2006
[HTML]<script type="text/javascript">
var theText = document.forms[0]["txtFieldName"].value;
</script>[/HTML]

That's how to reference a control in an HTML form, but after you submit? I don't get it. More info required.
==========================================
Yadda yadda yadda...
Web junky, fevered monkey
Reply With Quote  
Join Date: Dec 2004
Posts: 1,589
Reputation: tgreer is an unknown quantity at this point 
Rep Power: 7
Solved Threads: 34
Colleague
tgreer tgreer is offline Offline
Made Her Cry

Re: getting the text field value

  #5  
Aug 1st, 2006
If the text element has an ID, as it should it XHTML, the DOM method is:

document.getElementById['myId'].value

I'm not sure what you're hinting at by "after the submit", though, in your question.
Last edited by tgreer : Aug 1st, 2006 at 11:12 am.
Reply With Quote  
Join Date: Feb 2005
Location: Braintree, UK
Posts: 1,164
Reputation: hollystyles will become famous soon enough hollystyles will become famous soon enough 
Rep Power: 7
Solved Threads: 58
hollystyles's Avatar
hollystyles hollystyles is offline Offline
Veteran Poster

Re: getting the text field value

  #6  
Aug 1st, 2006
That won't work with square brackets, but with parentheses that is fine.

Both our methods are the best cross browser methods. As long as you avoid document.all or document.txtFieldName you should be ok.

I'm not sure what you're hinting at by "after the submit", though, in your question.

Well Covinus said:

how do I get The value I have entered in a textfield after submitting

And I'm trying to think of why would you want to reference a control in client side script after a submit? perhaps the submit is irrelevant in this case and a red herring just to keep us on our toes!
Last edited by hollystyles : Aug 1st, 2006 at 11:24 am.
==========================================
Yadda yadda yadda...
Web junky, fevered monkey
Reply With Quote  
Join Date: Mar 2006
Location: Philippines
Posts: 112
Reputation: Covinus is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
Covinus's Avatar
Covinus Covinus is offline Offline
Junior Poster

Re: getting the text field value

  #7  
Aug 1st, 2006
here is what i remember about my code.

var a = document.formname.textname.value generates an error mesasge

everytime i add this to my code nothing appears.
but when i remove the other stuff comes out.
if you cant hit 2 birds with one stone try hitting just one or you will end up with nothing at all
Reply With Quote  
Join Date: Mar 2006
Location: Philippines
Posts: 112
Reputation: Covinus is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
Covinus's Avatar
Covinus Covinus is offline Offline
Junior Poster

Re: getting the text field value

  #8  
Aug 1st, 2006
do you really need the semicolon in last line??? i found books that dont have ; in the end
if you cant hit 2 birds with one stone try hitting just one or you will end up with nothing at all
Reply With Quote  
Join Date: Dec 2004
Posts: 1,589
Reputation: tgreer is an unknown quantity at this point 
Rep Power: 7
Solved Threads: 34
Colleague
tgreer tgreer is offline Offline
Made Her Cry

Re: getting the text field value

  #9  
Aug 1st, 2006
JavaScript uses the semi-colon for line-termination. For the proper method(s) of placing the value of a textbox into a variable, please refer to the posts from myself and hollystyles in this thread.

If you have new, different questions about JavaScript, please start a new thread.
Reply With Quote  
Join Date: Feb 2005
Location: Braintree, UK
Posts: 1,164
Reputation: hollystyles will become famous soon enough hollystyles will become famous soon enough 
Rep Power: 7
Solved Threads: 58
hollystyles's Avatar
hollystyles hollystyles is offline Offline
Veteran Poster

Re: getting the text field value

  #10  
Aug 2nd, 2006
do you really need the semicolon in last line??? i found books that dont have ; in the end

It is true some browsers will run javascript without ; line terminators. But it is bad practice because the ECMA standard states ; is required and browser implimentations could change in the future. So any script you write without them, may work now but could be rendered useless after a browser upgrade.

I would say if you have books that omit ; they are out-of-date or just poor. If you can get hold of it in the Philippines I recommend the Javascript Anthology by James Edwards and Cameron Adams published by Sitepoint ISBN 0-9752402-6-9
Last edited by hollystyles : Aug 2nd, 2006 at 4:09 am.
==========================================
Yadda yadda yadda...
Web junky, fevered monkey
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb HTML and CSS Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the HTML and CSS Forum

All times are GMT -4. The time now is 12:07 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC