IT Community - Software Programming, Web Development and Technical Support

problem in javascript

This is a discussion on problem in javascript within the HTML, CSS and Javascript Coding Techniques forums, part of the Web Development category; <script language="Javascript"> function submitForm(action) { document.all.formlogin. innerHTML = document.all.formlogin.innerHTML + "<...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Web Development > HTML, CSS and Javascript Coding Techniques

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 05-06-2008, 12:51 AM
chetan1 chetan1 is offline
D-Web Trainee
 
Join Date: Apr 2008
Posts: 17
chetan1 is on a distinguished road
Default problem in javascript

<script language="Javascript">
function submitForm(action)
{
document.all.formlogin. innerHTML = document.all.formlogin.innerHTML +
"<input type=hidden name=statusx value=" + action + ">";
document.formlogin. submit();
}
</script>

<form name = "formlogin" action = "index.php" method = "POST">
UserName: <input type = "text" name = "UserName"></br></br>
PassWord: <input type = "password" name = "PassWord"></br></br>
<a class = "login" href="javascript: submitForm(\'temp\');"> Temporary Login</a></br>
<a class = "login" href="javascript: submitForm(\'perm\');"> Permanent Login</a>
</form>

I made such code, but once I click any of login links, my $_POST array has only statusx value, but not UserName and PassWord. What should I change?
__________________
web design company
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 05-06-2008, 01:57 AM
velhari velhari is offline
D-Web Programmer
 
Join Date: Mar 2007
Location: Chennai
Posts: 67
velhari is on a distinguished road
Send a message via AIM to velhari
Thumbs up Re: problem in javascript

Hi,

The way you had done(for adding hidden field to the form dynamically) in the submitForm function is not a good approach.

If you want to add an element dynamically means go by DOM approach.
Here in your case, it is also not needed.

From your logic, i understood that the one value passing to the JS function from that it will stored in dynamic hidden field and submitting the form.

Instead of going for dynamic hidden field, make that hidden field in the form itself and set the value dynamically to the hidden field by JS Function and submit the form, you will get the result[Its a Simple One, I think].

And finally, you didnt have the chance to face the browser compatibility(i think). Because, You had written document.all for getting the values. document.all is supported in IE Browser only not in firefox, safari etc.,
So, you have to take a look for these issues also.
__________________
Regards,
VELHARI
I am not totally useless. I can be used for a bad example
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 05-07-2008, 02:16 AM
chetan1 chetan1 is offline
D-Web Trainee
 
Join Date: Apr 2008
Posts: 17
chetan1 is on a distinguished road
Default Re: problem in javascript

ok buddy.
Whatever u say i will give attention but u said
Quote:
Instead of going for dynamic hidden field, make that hidden field in the form itself and set the value dynamically to the hidden field by JS Function and submit the form, you will get the result[Its a Simple One, I think].

i didn't understand.
__________________
web design company
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
a new problem? saravanan Computer Hardware 0 03-24-2008 06:09 AM
Problem in IE krishnakumar HTML, CSS and Javascript Coding Techniques 13 11-28-2007 08:51 PM
How does JavaScript Reporter differ from JavaScript editors? Pvinothkumar HTML, CSS and Javascript Coding Techniques 1 09-13-2007 04:59 AM
Problem on .net 3.0 WPF! theone C# Programming 0 07-19-2007 09:56 PM
DNS problem vadivelanvaidyanathan Server Management 0 07-15-2007 05:49 PM


All times are GMT -7. The time now is 05:37 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0