473,769 Members | 5,878 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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=javascr ipt:window.loca tion='edit.php? action=remote&I D=1234&pw='+thi s.form.password .value+;
VALUE=remote update>

The specific piece that I narrowed the error down to is:
+this.form.pass word.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 5168

tr****@gmail.co m wrote:
<INPUT TYPE=button
OnClick=javascr ipt:window.loca tion='edit.php? action=remote&I D=1234&pw='+thi s.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.pass word.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.locatio n='edit.php?etc =etc&pw=' +
this.form.eleme nts['password'].value;"
value = "remote update">

Sep 9 '06 #2
web.dev wrote:
tr****@gmail.co m wrote:
><INPUT TYPE=button
OnClick=javasc ript:window.loc ation='edit.php ?
action=remote& ID=1234&pw='+th is.form.passwor d.value+;
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.pas sword.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.locatio n='edit.php?etc =etc&pw=' +
this.form.eleme nts['password'].value;"
value = "remote update">
Wouldn't:-

<form action="edit.ph p" 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
3633
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 doing wrong? Thanks
12
3944
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 both single quotes and no single quotes, but it doesn't work either way. What am I doing wrong? <SCRIPT type='text/javascript'> function makeVisible(nameOfDiv) { document.getElementById('weblogs').style.visibility='hidden';
4
10712
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 within the form is a button bar and a <div> block which contains a table of parameters. The div block is used to create a layer.
3
2498
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 System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult) +174 System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult) +92
1
2219
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 IE 7+ and in Mozilla; seems to be OK in Firefox 1.0 for Linux. This is a time-sensitive issue that I can't seem to resolve, could someone come up with a quickie for me in this case? It seems the student's name is breaking things in Javascript...
1
13972
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 %> <html> <head>
4
22159
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 if(isset($_GET)) { echo "<div id="visible">"; echo "<span onclick="swapform()">Log In Form</span>"; echo "</div>"; echo "<div id="theform" style="visibility: hidden">";
4
1747
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: ************** Exception Text ************** System.Data.OleDb.OleDbException: Syntax error in INSERT INTO statement. at System.Data.Common.DbDataAdapter.Update(DataRow dataRows, DataTableMapping tableMapping) at...
5
1991
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 wrong with the code below? I have put a hyperlink on the aspx page. And I add the attributes of the hyperlink in my code-behind. I set the attributes in code behind because I need the AddressGuid ID value. I concattenate the value and make an URL...
0
9589
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10215
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
6674
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5307
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3964
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3564
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.