Solved

onchange syntax error

Posted on 2002-07-11
9
341 Views
Last Modified: 2008-03-10
in asp/vbscript i try to do this javascript




response.write ourSymbol & "<input type=text name='IT" & rs.fields.item("ProductID") & "' size=6

onChange='alert('This is a calculated field')'>"


which gives


&euro;<input type=text name='IT27' size=6 onChange='alert('This is a calculated field')'>


but it says theres a syntax error??
0
Comment
Question by:boofulls
  • 4
  • 3
  • 2
9 Comments
 
LVL 33

Expert Comment

by:knightEknight
ID: 7145916
onChange='alert(\'This is a calculated field\')'>
0
 
LVL 10

Expert Comment

by:zvonko
ID: 7145920
Try this:
response.write "<<script>var msg1 = 'This is a calculated field'</script>"
response.write ourSymbol & "<input type=text name='IT" & rs.fields.item("ProductID") & "' size=6 onChange='alert(msg1)'>"

Good luck,
zvonko



0
 
LVL 33

Expert Comment

by:knightEknight
ID: 7145927
or, if you want double-quotes in VBScript, then you double them:

response.write ourSymbol & "<input type='text' name='IT" & rs.fields.item("ProductID") & "' size='6'
onChange='alert(""This is a calculated field"")'>"
0
 
LVL 10

Expert Comment

by:zvonko
ID: 7145933
Sorry, a typo. Here corrected:
Try this:
response.write "<script>var msg1 = 'This is a calculated field'</script>"
response.write ourSymbol & "<input type=text name='IT" & rs.fields.item("ProductID") & "' size=6 onChange='alert(msg1)'>"

Of course is a better idea to place all strings into variables in <head> section.

Cheers,
zvonko

0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:boofulls
ID: 7146075
knighteknight

i try this

or, if you want double-quotes in VBScript, then you double them:

response.write ourSymbol & "<input type='text' name='IT" & rs.fields.item("ProductID") & "' size='6'
onChange='alert(""This is a calculated field"")'>"


it works but when i edit the field it stays edited, i want it to not editable

thanks
0
 
LVL 33

Accepted Solution

by:
knightEknight earned 20 total points
ID: 7146085
try adding this in the tag:

onFocus='this.blur();'
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 7146088
... instead of the onChange (which is not needed if that is all you want to do)
0
 

Author Comment

by:boofulls
ID: 7146090
zvonko


this works too

response.write "<script>var msg1 = 'This is a calculated field'</script>"
response.write ourSymbol & "<input type=text name='IT" & rs.fields.item("ProductID") & "' size=6 onChange='alert(msg1)'>"



but again id like the field to not be editable

thanks
0
 
LVL 10

Expert Comment

by:zvonko
ID: 7146188
Hey, this is experts exchange :)

0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now