By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,545 Members | 840 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,545 IT Pros & Developers. It's quick & easy.

Passing text from JavaScript function to XHTML

P: 55
I am trying to a pass "text sentence" from a JavaScript function into my XHTML program is this possible??

JavaScript function validate.pdf

Please see attached attached JavaScript coding.

The reason why I am trying to pass text from JavaScript to my XHTML program is, because depending on whether or not a certain input field is filled out or not I want certain text to be displayed within my XHTML page...

Regards
Gary Wilson
Apr 25 '10 #1
Share this Question
Share on Google+
5 Replies

RamananKalirajan
100+
P: 607
Yes you can do that. Either you can alert the text to show the user that this field is missing. Otherwise have a div in the HTML and print the text in that div

sample Code
HTML:
Expand|Select|Wrap|Line Numbers
  1. <div id="errorMsg">
  2. </div>
Js
Expand|Select|Wrap|Line Numbers
  1. document.getElementById('errorMsg').innerHTML=alerttext;
Thanks and Regards
Ramanan Kalirajan
Apr 25 '10 #2

P: 55
@RamananKalirajan
Thanks Ramanan, for the info.

In my situation I would prefer not to use 'alerttext' popup and rather display the text directly in a area (but not a text area) within the XHTML document.

I like the div method though. Where do you place the function "document.getElementById('errorMsg').innerHTML=ale rttext;", would this be inside my function "validate_required"??

Thanks and regards
Gary Wilson
Apr 25 '10 #3

RamananKalirajan
100+
P: 607
Yes you have to include that line in the validate_required method. Where the condition fails.

Thanks and Regards
Ramanan Kalirajan
Apr 25 '10 #4

P: 55
@RamananKalirajan
Thanks, I have tested this and it works well :)
Apr 25 '10 #5

RamananKalirajan
100+
P: 607
Good. Keep Moving forward. Post back if you have any doubts.

Thanks and Regards
Ramanan Kalirajan
Apr 25 '10 #6

Post your reply

Sign in to post your reply or Sign up for a free account.