JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old December 2nd, 2005, 05:05 AM
Micster Micster is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2005
Posts: 5 Micster User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 23 m 19 sec
Reputation Power: 0
Button Value not updating when Changed

Hi,

I want to get users to verify their email addresses before submitting my form using the following code [the alerts have been added to help debugging]:

Code:
<script language="JavaScript" type="text/JavaScript">
function presssave(Buttjs, Emailjs) {
	alert(Buttjs.value);
	Buttjs.value='Pressed';
	alert(Buttjs.value);
	var x=window.confirm("You will use your email address to login.\n\nPlease check it carefully before carrying on.      \n\n       "+Emailjs.value+"\n\nIs this correct ?");
	if (x) {
		document.UserDetails.submit();
	}else{
		Emailjs.focus()
	}
}
</script>


This works apart from setting the value of the button to 'Pressed' while the confirm box is shown. I have another page and form where this seems to work fine.

I have added the alerts to try and track what is going on. They tell me that the value of the button has been changed to 'Pressed', but it still shows 'Save' as it did to start with.

What have I done wrong? I have spent ages trying to work it out without success. Any ideas gratefully receieved!

Reply With Quote
  #2  
Old December 2nd, 2005, 08:20 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 4 m 48 sec
Reputation Power: 8
I didn't change a thing, but made your example bigger for my own testing...

Code:
<html>
<head>
<script language="JavaScript" type="text/JavaScript">
function presssave(Buttjs, Emailjs) {
	alert(Buttjs.value);
	Buttjs.value='Pressed';
	alert(Buttjs.value);
	var x=window.confirm("You will use your email address to login.\n\nPlease check it carefully before carrying on.      \n\n       "+Emailjs.value+"\n\nIs this correct ?");
	if (x) {
		//document.UserDetails.submit();
		alert("Submit");
	}else{
		Emailjs.focus()
	}
}
</script>
</head>

<body>
<input type="text" id="email" />
<input type="button" name="button1" value="Save" onclick="javascript:presssave(this, document.getElementById('email'));" />
</body>
</html>


Testing in Firefox 1.0.7, IE6, and Opera 8.5... it seems to work...
Again, I didn't change a thing =)

Let me know if my test page here works for you...
There may be something else funky going on with your original page.

Reply With Quote
  #3  
Old December 4th, 2005, 03:43 PM
Micster Micster is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2005
Posts: 5 Micster User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 23 m 19 sec
Reputation Power: 0
Thanks MadCowDzz. I haven't tried it yet, but will over the next couple of days.

For some reason on my page, the button is not being posted at all (IE or Netscape, haven't tried FireFox). I was checking for this POST in PHP to decide whether to save new or update an existing MySQL user record.

I have now changed the way this works so am over the urgency of the problem - but I don't like leaving things like this without understanding what's going on! Be back to you soon.

Reply With Quote
  #4  
Old December 5th, 2005, 12:03 PM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 4 m 48 sec
Reputation Power: 8
As I said, I didn't change your code one bit.

It may have to do with the placement of your javascript blocks?

Let us know if my example above works for you.
__________________
Daryl's Homepage | My Blogroll | My Profile | Firefox supporter!
DevArticles Forum Moderator

"The net is a waste of time, and that's exactly what's right about it." -- William Gibson

Reply With Quote
  #5  
Old February 20th, 2006, 10:12 AM
squeegee squeegee is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2006
Posts: 1 squeegee User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 m 8 sec
Reputation Power: 0
From what I can surmise from W3C and WDG , input type=button does not get posted, but is only useful for client-side scripting.
Comments on this post
MadCowDzz agrees!

Reply With Quote
  #6  
Old February 20th, 2006, 01:24 PM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 4 m 48 sec
Reputation Power: 8
Squeegee, you're absolutely correct, and it's definitely worth noting.

The button in the code above doesn't seem to be used for submitting a form but rather triggering the Javascript. This is a push button serving it's primary purpose =)

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJavaScript Development > Button Value not updating when Changed


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Iron Speed




© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway