Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Need Help with setAttribute

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,33727
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Need Help with setAttribute
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Need Help with setAttribute - 4/20/2006 11:44:07 AM   
  MaddMan79

 

Posts: 15
Score: 0
Joined: 4/17/2006
Status: offline
Hi Guys,

I seem to be having troubles with the setAttribute syntax. All I want to do is update values in forms:

      

What am I doing wrong??

-Brian
 
 
Post #: 1
 
 RE: Need Help with setAttribute - 4/21/2006 12:58:59 AM   
  ebgreen


Posts: 5246
Score: 31
Joined: 7/12/2005
Status: offline
What happens when you execute that code? Any error? Do you have On Error Resume Next anywhere in your script?

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to MaddMan79)
 
 
Post #: 2
 
 RE: Need Help with setAttribute - 4/21/2006 1:28:57 AM   
  ehvbs

 

Posts: 2220
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Hi ,

AFAIK, there is no input type "form" (cf. http://www.w3.org/TR/html4/interact/forms.html#input-control-types).
Please try to test your code with a type like "text", and tell us about the results.

Good luck.

(in reply to ebgreen)
 
 
Post #: 3
 
 RE: Need Help with setAttribute - 4/21/2006 3:12:21 AM   
  MaddMan79

 

Posts: 15
Score: 0
Joined: 4/17/2006
Status: offline
Thanks for your replies... I know that this is something so stupid... but, I can't get it to work!

All I'm trying to do is update the 'value' of input elements. I've tried input types 'button', 'form', and 'text'. I don't receive any errors... but, 'value' doesn't update either.

@ebgreen, I'm not using any sort of On Error Resume Next. I tried doing this in my code... and in the example you gave me from the other thread. This is what I'm trying to do:

      

When I run this example, the button still displays 'Old Caption'. Am I making a false assumption about how I can use the setAttribute method?

Thanks,

Brian

(in reply to ehvbs)
 
 
Post #: 4
 
 RE: Need Help with setAttribute - 4/21/2006 3:52:32 AM   
  ebgreen


Posts: 5246
Score: 31
Joined: 7/12/2005
Status: offline
I would say just make the change when you create the element:


strButtonVal = "New Caption"
Set oButton = document.createElement("<INPUT TYPE='button' ID='btn1' VALUE='" & strButtonVal & "' ONCLICK='buttonClick()'>")
          

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to MaddMan79)
 
 
Post #: 5
 
 RE: Need Help with setAttribute - 4/21/2006 4:31:19 AM   
  MaddMan79

 

Posts: 15
Score: 0
Joined: 4/17/2006
Status: offline
That's what I was trying at first... but, I got a little distracted by the constant redrawing...

Anyways, I found a solution:

      

Too bad setAttribute doesn't allow for this...

Anyways, hope this helps!

-Brian

(in reply to ebgreen)
 
 
Post #: 6
 
 RE: Need Help with setAttribute - 4/21/2006 5:04:12 AM   
  ehvbs

 

Posts: 2220
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Hi MaddMan79,

again somebody too fast for me! But if you like to compare notes - ah codes ...


      

And: I really would like to have a plausible explanation.

(in reply to MaddMan79)
 
 
Post #: 7
 
 RE: Need Help with setAttribute - 4/21/2006 5:15:32 AM   
  ebgreen


Posts: 5246
Score: 31
Joined: 7/12/2005
Status: offline
What did you want a plausible explanation of?

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to ehvbs)
 
 
Post #: 8
 
 RE: Need Help with setAttribute - 4/24/2006 6:50:14 AM   
  ehvbs

 

Posts: 2220
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
I was wondering why

     (1) Set oButton = document.createElement("<INPUT TYPE='button' ID='btn1' VALUE='Old Caption' ONCLICK='buttonClick()'>")
     (2) oButton.setAttribute "Value", "New Caption"
            
didn't work. Because somebody who doesn't state his questions clearly has to provide the answer
himself, I tried to think (always difficult!), did some tests, and googled until I could identify the
culprits:

  (1) value is "VALUE" in line 1 
  (2) value is "Value" in line 2
  (3) value is value (all lowercase) in HTML/DOM
  (4)  setAttribute( sName, vValue [, iFlags ] )
         iFlags = 0: ignore case
         iFlags = 1 (default): honor case
        [see http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/setattribute.asp]

Therefore

    oButton.setAttribute "Value", "New Caption", 0
    oButton.setAttribute "value", "New Caption", 1

are okay (tested).

(in reply to ebgreen)
 
 
Post #: 9
 
 RE: Need Help with setAttribute - 4/24/2006 9:58:35 AM   
  MaddMan79

 

Posts: 15
Score: 0
Joined: 4/17/2006
Status: offline
ehvbs,

I had no idea that this was a case related issue! That was a good catch ;)

I'll admit... since I've been coding with VBScript, I've gotten a little more lazy about staying consistent with case. I'll watch out for that!

Thanks for taking the time to find the root of the problem

-Brian

(in reply to ehvbs)
 
 
Post #: 10
 
 RE: Need Help with setAttribute - 4/25/2006 1:19:40 AM   
  ebgreen


Posts: 5246
Score: 31
Joined: 7/12/2005
Status: offline
Hear, hear. Excellent detective work.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to MaddMan79)
 
 
Post #: 11
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Need Help with setAttribute Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts