469,640 Members | 1,563 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,640 developers. It's quick & easy.

Passing text from JavaScript function to XHTML

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
5 1621
RamananKalirajan
607 512MB
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
neogazz
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
607 512MB
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
neogazz
55
@RamananKalirajan
Thanks, I have tested this and it works well :)
Apr 25 '10 #5
RamananKalirajan
607 512MB
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.

Similar topics

1 post views Thread by Greg | last post: by
1 post views Thread by mmalloc | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.