Link to home
Start Free TrialLog in
Avatar of bryan oakley-wiggins
bryan oakley-wigginsFlag for United Kingdom of Great Britain and Northern Ireland

asked on

dhtml document.write onclick button

Hi

I have a colleague that has asked me to ask the following question - Thanks in advance for any feedback/comments.

I have copied the code to the below. I want the display message to show only when the "DISPLAY" button is clicked. At the moment the message shows first then the "DISPLAY" button and when the button is clicked nothing happens.


***START OF CODE***

<html>
<script language = vbscript>
sub Onload
      document.write "click the display button to show the message <br>"
      document.write "<Input Type=button Value=Display Onclick=" & display & ">"
End sub
Function display
      msgbox "You have clicked the display button ;-)"
End Function
</script>
<body onload="OnLoad()">
</body>
</html>

***END OF CODE***

Cheers
Bry
ASKER CERTIFIED SOLUTION
Avatar of Göran Andersson
Göran Andersson
Flag of Sweden image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bryan oakley-wiggins

ASKER

Hi GreenGhost and daveamour

Thank you so much for getting back with the solution so quickly. My colleague is extremely happy, so again thanks so much for that.

I will split the points - DO you feel the 250 allocation was ok for this question?

I am happy to up the points to 500 for a 250 split (if I am able to?) as you have saved my colleague some major headache..!

Cheers
Bry
I'm happy as it is, always glad to help.  I know how much it hurts when you can't get something working!
Best to stick to Javascript though unless you have a good reason not to.
daveamour

Thanks, your very quick help and expertise was extrememly helpful and it's good to see my colleague smiling again (especially as it's Friday :-)

Thanks also for the heads-up on jscript

Again thanks
Bry
You are welcome and now maybe your colleague should join EE too!
he he yes, I believe he is signing-up as we speak :-)
My friend Bryan actually posted the code on my behalf cos I did not have an account. I was really impress with the quick response and signed up 10 mins ago. I now need to ask another quick question on how I can display the message on the right window frame.
Original solution from daveamour
document.getElementById("MyDiv").innerHTML = "click the display button to show the message <br><input type=""button"" value=""Display"" onclick=""call Display()"">"
 my code and I am getting errors relating to objects...
Window.parent.frames(1).document.getElementById("MyDiv").innerHTML = "click the display button to show the message <br><input type=""button"" value=""Display"" onclick=""call Display()"">"
I am not sure if I need to add some code in the Form tag????
 
 Thanks in advance