473,379 Members | 1,201 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

syntax error OnClick

I hope this is a simple fix, but it has been driving me crazy, I have
the following code, that errors out with a syntax error:

<INPUT TYPE=button
OnClick=javascript:window.location='edit.php?actio n=remote&ID=1234&pw='+this.form.password.value+;
VALUE=remote update>

The specific piece that I narrowed the error down to is:
+this.form.password.value+;

If I exclude this, it works fine, but in my app I want to be able to
append the password field value from the form. Please help as I am by
no means a javascript expert, but just want to append the form field
value to the OnClick string.

Thanks

Sep 8 '06 #1
2 5134

tr****@gmail.com wrote:
<INPUT TYPE=button
OnClick=javascript:window.location='edit.php?actio n=remote&ID=1234&pw='+this.form.password.value+;
VALUE=remote update>
1. Do not use the javascript pseudo-protocol. It doesn't belong here
and is not needed.
2. It's generally a good idea to place quotes around attribute values.
The specific piece that I narrowed the error down to is:
+this.form.password.value+;
The last addition is not necessary.

Assuming you have an input element that's a password type with a name
'password', recommended solution is the following:

<input type = "password" name = "password">
<input type = "button"
onclick = "window.location='edit.php?etc=etc&pw=' +
this.form.elements['password'].value;"
value = "remote update">

Sep 9 '06 #2
web.dev wrote:
tr****@gmail.com wrote:
><INPUT TYPE=button
OnClick=javascript:window.location='edit.php?
action=remote&ID=1234&pw='+this.form.password.val ue+;
VALUE=remote update>

1. Do not use the javascript pseudo-protocol. It
doesn't belong here and is not needed.
In the context of an intrinsic event attribute the - javascript: - is
the syntax for a label. A worthless label as no - break - or -
continue - statement refers to it, or would be meaningful in the code.
2. It's generally a good idea to place quotes around
attribute values.
It is a requirement of valid HTML that quotes be used around attribute
values that contain certain characters, and those characters are common
in javascript source code.

It is also likely that the HTML parser may see the character sequences -
&ID - and - &pw - as unrecognised entities so they probably should be -
&amp;ID - and - &amp;pw -.
>The specific piece that I narrowed the error down to is:
+this.form.password.value+;

The last addition is not necessary.
And a javascript syntax error.
Assuming you have an input element that's a password
type with a name 'password', recommended solution is
the following:

<input type = "password" name = "password">
<input type = "button"
onclick = "window.location='edit.php?etc=etc&pw=' +
this.form.elements['password'].value;"
value = "remote update">
Wouldn't:-

<form action="edit.php" method="GET">
<input type="hidden" name="ID" value="1234">
<input type="hidden" name="action" value="remote">
<input type="password" name="pw">
<input type="submit" value="remote update">
</form>

- be better yet as it is functional without any javascript dependency at
all. Though if any field is a password field sending the password value
as a text on a query string makes its interception trivial. A POST
request would be preferable.

Richard.
Sep 9 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Kevin | last post by:
Hi, I am getting a syntax error Microsoft VBScript compilation error '800a03ea' Syntax error On the code below. The error references the "End Select" line Can anyone help me with what I am...
12
by: lawrence | last post by:
The following function correctly makes everything invisible but then fails to turn the one chosen DIV back to visible. I imagine I'm getting the syntax of the variable wrong? I've tried this with...
4
by: Bradley Kite | last post by:
Hi all. I'm trying to diagnose/solve a problem with internet explorer, whereby sometimes the form submits, and other times IE produces an 'invalid syntax' error. First, I have a form, and...
3
by: Nathan Sokalski | last post by:
When trying to submit data to an Access database using ASP.NET I recieve the following error: System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(Int32 hr) +41...
1
by: Phil Powell | last post by:
&lt;input type="submit" name="delete_student" value="Delete Applicant" onClick="setSubmitVal(this); return willDeleteApplicant('O&amp;#039;Connor, Kerry B');"&gt; This HTML tag causes Javascript errors in...
1
by: DaveF | last post by:
Any Ideas as to this error message. I am trying to learn using ms sql server 7.0 Below is the code I am using for an update to a MS Sql Database. <%@ Language=VBScript %> <% Option Explicit...
4
kestrel
by: kestrel | last post by:
I have some html code that is supposed to be displayed by php echo. But for some reason i keep getting a syntax error, and i cant figure out what is going on. Heres what i have <?php...
4
by: hathan | last post by:
Hi, i am trying to add a new row into a microsoft access database and cant understand why it wont work. Can anyone please help me understand what this means? The error message says: **************...
5
by: mesut | last post by:
Hi there, how are you colleagues? I try to set a linkaddress in code behind for a <asp:hyperlinkserver control. but I think I have some syntax problem. I don't know how to fix it. What's...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.