473,761 Members | 4,739 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

problem with textfield name containing square brackets

Hi there

I'm hoping that someone can help me with a question I have about
javascript syntax.

I got an html page that uploads an image and some text field to a
database.

What I'd like to do is modify the content of one of the textfields
prior to it being submitted to the database. Specifically, I need to
append the contents of one of the fields to another.

The problem that I've encountered is that the textfield name contains
square brackets , ‘extra_fields[Price]'

I've identified the square brackets as being the problem by changing
the textfield's name to one that doesn't contain square brackets
,extra_fieldPri ce for example and the script works fine.

Unfortunately, in the real world application of this page, I can't
change the textfield name.

The specific part of the html page that's giving me problems is
<input type="button" value="Click to generate code" class="body-text"
onClick="extra_ fields[Price].value =
'$'+extra_field s[Price].value+'<br><A
HREF=&quot;../cgi-bin/processorder.cg i?'+caption.val ue+'~'+extra_fi elds[Price].value+'&quot;> Add
to Order</A>'"></input>
I've tried puting backslashes before the square bracket,

"onClick="extra _fields\[Price\].value =
'$'+extra_field s\[Price\].value+'<br><A
HREF=&quot;../cgi-bin/processorder.cg i?'+caption.val ue+……………….."
Unfortunately the script didn't still doesn't work though.

I'm not that familiar with javascript syntax. Can anyone suggest how I
can have javascript read square brackets as a literal part of a
textfield's name rather than as some kind of syntax modifier
The entire page's html is as follows

Thanks for any suggestions
<html>
<head>
<title>Add Item</title>

<script language="Javas cript">
<!--
function reloadPage() {
document.count_ form.submit();
return false;
}
// -->
</script>
</head>
<body>
<span class="popuphea d">Add Photo</span>
<br>
<span class="popup">
Click the <b>Browse</b> button to locate a photo to upload.
<span class="admin">
<br>
&nbsp;&nbsp;(Su pported file types: jpg, jpeg, gif, png, avi, mpg,
mpeg, wmv, mov, swf)
</span>

<br><br>

<form action="xxxxxxx xxx/products/add_photo.php" name="upload_fo rm"
enctype="multip art/form-data" method="POST">
<input type=hidden name="" value="">
<input type="hidden" name="max_file_ size" value="10000000 ">
<table>
<tr><td>
File</td>
<td><input name="userfile" type="file" size=40></td>
</tr>
<td>Caption</td>
<td> <textarea name="caption" rows=2 cols=40></textarea></td>
</tr>
<tr>
<td valign=top>Desc ription</td><td><textare a
name="extra_fie lds[Description]" rows=2 cols=40></textarea></td
</tr>

<tr>
<td valign=top>Dime nsions</td>
<td><textarea name="extra_fie lds[Dimensions]" rows=2
cols=40></textarea></td>
</tr>
<tr>
<td valign=top>Pric e</td>
<td><textarea name="extra_fie lds[Price]" rows=2
cols=40></textarea></td>
</tr>
</table>
<input type=checkbox name=setCaption checked value="1">Use filename as
caption if no caption is specified.
<br>

<input type="button" value="Click to generate code" class="body-text"
onClick="extra_ fields[Price].value =
'$'+extra_field s[Price].value+'<br><A
HREF=&quot;../cgi-bin/processorder.cg i?'+caption.val ue+'~'+extra_fi elds[Price].value+'&quot;> Add
to Order</A>'"></input>

<input type="button" value="Upload Now"
onClick='opener .showProgress() ; document.upload _form.submit()' >
<input type=submit value="Cancel" onclick='parent .close()'>

</form>

</body>
</html>
Jul 20 '05 #1
1 6434
"Veverita" <mo***@email.co m> wrote in message
news:d9******** *************** **@posting.goog le.com...
<snip>
The problem that I've encountered is that the textfield
name contains square brackets , 'extra_fields[Price]' <snip>Unfortunatel y, in the real world application of
this page, I can't change the textfield name.

<snip>

Real world applications should not be built using invalid HTML.

< URL: http://www.jibbering.com/faq/#FAQ4_25 >

- and -

< URL: http://www.jibbering.com/faq/#FAQ4_39 >

Richard.
Jul 20 '05 #2

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

Similar topics

7
11914
by: CharlesEF | last post by:
Hi All, I have run into another problem that is eating my lunch. Should be simple but I am having one heck of a time. Please look at this SELECT statement: SELECT FROM States WHERE ] = "US"; is the SQL column name (because it sarts with 2?). As the statement is shown I get the error message: Unclosed quotation mark before the character
2
1163
by: Mark Rodseth | last post by:
Okay, this is really annoying me so if you can help I'll be very gratefull. I am trying to send an email using the System.Web.Mail Namespace - MailMessage and SMTPMail classes - and something very strange is happening. When I set the EmailFrom field, for example "Joe Bloggs <joebloggs@domain.com>", the angle brackets are converted to square brackets. I need the angle brackets to stay
11
3075
by: Eych | last post by:
I get a VB error when I try to update a table whose field I change with the following statement: dcUpdate.Dataset.Tables(0).Rows(0)("User Name") = Me.textbox1.Text if I change the field name to "UserName", one word, in the table and in the statement above, it works... realistically, I can't do this since the users already have a copy of
9
1470
by: turnitup | last post by:
Dear All, I have RTFM'd until I am blue in the face and I am completely at a loss. I would be grateful for any help. I have a series of elements in my html called var1, var2, var3 etc I want to be able to pass a number to a function to get details of that property such that eg...
73
3846
by: Markus | last post by:
Hi, I can't understand why this code causes a "memory read exception" at int x=**a; void pass(int** a) { int x=**a; } void main()
3
3254
by: touf | last post by:
Hi, I've an error when using this expression myDataview.rowfilter="client id = '1111'" this is because the field name "client id" that contain a space. I don't have the possibility to change the query (to add an alias for example), what is the solution Thanks.
2
6110
by: shadowman | last post by:
So here's the situation: I need to write a PHP script which accepts form submissions using all methods (GET and POST) and all content types (application/x-www-form-url-encoded and multipart/form-data). And for POST method, it has to be able to get the exact bit-for-bit accurate contents of the POST body. Now here's the problem: I'm stuck with POST multipart/form-data. The $GLOBALS only works with application/x-www-form-url-encoded. It...
30
2838
by: Einstein30000 | last post by:
Hi, in one of my php-scripts is the following query (with an already open db-connection): $q = "INSERT INTO main (name, img, descr, from, size, format, cat, host, link, date) VALUES ('$name', '$img', '$descr', '$user', '$size', '$format', '$cat', '$host', '$link', '$date')" or die(mysql_error()); And when the query gets executed i get back the following error:
8
11665
hsriat
by: hsriat | last post by:
I need to compare a string with a regular expression that contains square brackets in itself. eg. If I test() a regExp ("^]", "i") with string "]Bold Text]", it should return true. But its returning false due to square brackets. How can I solve this? var txt = "]Page starts]"; function matchTag(start) { var regStart = new RegExp("^", "i"); if (regStart.test(txt)) alert ('Matching');
0
9377
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
9989
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9925
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8814
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7358
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6640
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();...
1
3913
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
3
3509
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2788
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.