sonofagun
Junior Member
Posts: 2
Registered: 6/18/2003
Location: Cairns Australia
Member Is Offline
|
| posted on 6/18/2003 at 12:44 AM |
|
|
problem with formfield name php variable
Hi,
I am writting a booking form script for my website and have decided to include the Tigra Calendar. My problem is that the form field name changes for
each new booking added. Basically what happens is that when "add new booking" is selected the next record id is appended to the field name
i.e If the field is named Indate, once php has processed the page the form field name appears as Indate(3). 3 is the next record id. I have provided
the code in two sections.
1) PHP Script
2) The processed page output
1)<td nowrap bgcolor="#1e90ff"><input name='outdate(<?php echo $cnsaptsbookings->AbsolutePosition()?>)'
value='<?php echo fixHTMLquotes($cnsaptsbookings->Value("outdate")) ?>' size="12"
onfocus="this.blur()"><a href="javascript:void(0)" onclick="gfPop.fEndPop(document.cnsapts.indate(<?php echo
$cnsaptsbookings->AbsolutePosition()?>),document.cnsapts.outdate(<?php echo $cnsaptsbookings->AbsolutePosition()?>));return
false;" HIDEFOCUS><img name="popcal" align="absbottom" src="calbtn.gif" width="34"
height="22" border="0" alt=""></a></td>
2) <td nowrap bgcolor="#1e90ff">
<input name='indate(4)' value='' size="12" onfocus="this.blur()"><a
href="javascript:void(0)" onclick="gfPop.fStartPop(document.cnsapts.indate(4),document.cnsapts.outdate(4));return false;"
HIDEFOCUS><img name="popcal2" align="absbottom" src="calbtn.gif" width="34" height="22"
border="0" alt=""></a></td>
I don't know much about Javascript but I have a feeling it doesn't like the outputted syntax.
Any Help would be appreciated.
Best Regards
Steve Laws
|
|
|
nik
Posts:
Registered: 1/1/1970
Member Is Offline
|
| posted on 6/18/2003 at 02:37 PM |
|
|
It's not preferable to use brackets in input names. () in JavaScript usually follow function name or are used for priority indication in
arithmetical expressions. That's why construction
document.cnsapts.indate(4)
isn't reference to form element for JavaScript. So you should use the following construction:
document.forms['cnsapts'].elements['indate(4)']
|
|
|
sonofagun
Junior Member
Posts: 2
Registered: 6/18/2003
Location: Cairns Australia
Member Is Offline
|
| posted on 6/19/2003 at 04:08 AM |
|
|
Thanks
Worked like a charm.
Many thanks for your help.
Regards
Steve
|
|
|