Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2009-05-04
3
Medium Priority
?
1,656 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 1200 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 300 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

These days socially coordinated efforts have turned into a critical requirement for enterprises.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

718 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