problem with textfield name containing square brackets

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Veverita

    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[color=blue]
    ></tr>[/color]
    <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>
  • Richard Cornford

    #2
    Re: problem with textfield name containing square brackets

    "Veverita" <mokus@email.co m> wrote in message
    news:d9f51296.0 307241552.3901c 5b@posting.goog le.com...
    <snip>[color=blue]
    >The problem that I've encountered is that the textfield
    >name contains square brackets , 'extra_fields[Price]'[/color]
    <snip>[color=blue]
    >Unfortunatel y, in the real world application of
    >this page, I can't change the textfield name.[/color]
    <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.


    Comment

    Working...