Link to home
Start Free TrialLog in
Avatar of boofulls
boofulls

asked on

onchange syntax error

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??
Avatar of knightEknight
knightEknight
Flag of United States of America image

onChange='alert(\'This is a calculated field\')'>
Avatar of zvonko
zvonko

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



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"")'>"
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

Avatar of boofulls

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of knightEknight
knightEknight
Flag of United States of America 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
... instead of the onChange (which is not needed if that is all you want to do)
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
Hey, this is experts exchange :)