473,385 Members | 1,465 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,385 software developers and data experts.

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_fieldPrice 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_fields[Price].value+'<br><A
HREF=&quot;../cgi-bin/processorder.cgi?'+caption.value+'~'+extra_fields[Price].value+'&quot;>Add
to Order</A>'"></input>
I've tried puting backslashes before the square bracket,

"onClick="extra_fields\[Price\].value =
'$'+extra_fields\[Price\].value+'<br><A
HREF=&quot;../cgi-bin/processorder.cgi?'+caption.value+……………….."
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="Javascript">
<!--
function reloadPage() {
document.count_form.submit();
return false;
}
// -->
</script>
</head>
<body>
<span class="popuphead">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;(Supported file types: jpg, jpeg, gif, png, avi, mpg,
mpeg, wmv, mov, swf)
</span>

<br><br>

<form action="xxxxxxxxxx/products/add_photo.php" name="upload_form"
enctype="multipart/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>Description</td><td><textarea
name="extra_fields[Description]" rows=2 cols=40></textarea></td
</tr>

<tr>
<td valign=top>Dimensions</td>
<td><textarea name="extra_fields[Dimensions]" rows=2
cols=40></textarea></td>
</tr>
<tr>
<td valign=top>Price</td>
<td><textarea name="extra_fields[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_fields[Price].value+'<br><A
HREF=&quot;../cgi-bin/processorder.cgi?'+caption.value+'~'+extra_fields[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 6383
"Veverita" <mo***@email.com> wrote in message
news:d9*************************@posting.google.co m...
<snip>
The problem that I've encountered is that the textfield
name contains square brackets , 'extra_fields[Price]' <snip>Unfortunately, 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
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 ] =...
2
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...
11
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...
9
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...
73
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
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...
2
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...
30
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',...
8
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...
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
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: 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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?

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.