Solved

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

Posted on 2009-05-04
3
1,648 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.

732 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