get value of form element in same page

  • dheerhot
  • Novice
  • Novice
  • User avatar
  • Joined: Jan 11, 2009
  • Posts: 34
  • Status: Offline

Post February 13th, 2009, 11:40 am

hello again, normally we used to post values of form elements to other page or in database, but here i want to collect its value in the same page without submitting the form, like happens in java script, by using getElementById() method..

Same thing i want to do in php ..

suppose i hve below form say test1.php...

Code: [ Select ]
<form name="test" method="post" action="">
<input type="text" name"t1" id="t1" value="">
<select name="s1"><option value="cricket">Cricket</option>
<option value="football">Football</option>
</select>
<input type="submit" name"sub1">
</form>
  1. <form name="test" method="post" action="">
  2. <input type="text" name"t1" id="t1" value="">
  3. <select name="s1"><option value="cricket">Cricket</option>
  4. <option value="football">Football</option>
  5. </select>
  6. <input type="submit" name"sub1">
  7. </form>


now i want to get the values of textfield & combo box in the same page i.e. test1.php, without submitting the form...
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post February 13th, 2009, 11:40 am

  • joebert
  • Sledgehammer
  • Genius
  • No Avatar
  • Joined: Feb 10, 2004
  • Posts: 13458
  • Loc: Florida
  • Status: Offline

Post February 13th, 2009, 3:24 pm

Be a little more specific about what your over-all goal is please.
Strong with this one, the sudo is.
  • Bogey
  • Bogey
  • Genius
  • User avatar
  • Joined: Jul 14, 2005
  • Posts: 8212
  • Loc: USA
  • Status: Offline

Post February 13th, 2009, 3:32 pm

You'll have to submit the form... except the action would lead to it's own page and it would print the values accordingly... otherwise, you can use JavaScript associated with PHP to accomplish what you want.

You can use the JavaScript to print the values from the Form to the screen, and the PHP to process the information. I can't help you hear as I just started to learn JavaScript but someone else could tell you how to do this.

@joebert: He basically wants the information to be processed on the same page... and I assume he wants it done without the page refreshing...
"Bring forth therefore fruits meet for repentance:" Matthew 3:8

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: No registered users and 100 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.