Solved

How to let HTML input text value from javascript function call return value?

Posted on 2009-05-04
3
1,653 Views
Last Modified: 2013-11-19
I have a HTML page with form and various input fields. However, the default value of some input fields should be calculated dynamically from return value of some java script. Also when the submit type button is clicked, all input fields should be validated before invoking the sever side PHP script. Could someone tell me how to do it? Thanks!
0
Comment
Question by:gs_kanata
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 41

Accepted Solution

by:
HonorGod earned 400 total points
ID: 24301062
You are going to have to supply more information.  For example, what kind of fields, and what kind of validation.  It is quite common to see a form tag something like this:

When the submit button is clicked, the specified function (in this case validateFormOnSubmit() ) is called to check for valid values in each of the form elements.

If the values are acceptable, the function returns a value of true, and the action event will be used.  Otherwise a value of false is returned, and the user  is able to correct the issues.
<form name='myForm' onsubmit='return validateFormOnSubmit(this)' action='target.html'>

Open in new window

0
 
LVL 4

Assisted Solution

by:bleach77
bleach77 earned 100 total points
ID: 24302295
Write a function that will change the value. Something like this:

document.myForm.txtbox.value = "New Value";

Call the function like HonorGod post. The javascript will change the value before submitting the form.
0
 
LVL 41

Expert Comment

by:HonorGod
ID: 24408468
Thanks for the grade & points.  I'm sorry that you didn't feel the answer warranted an A.

Good luck & have a great day.
0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

635 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question