View Full Version : making one text area dependant on another

03-20-2009, 03:32 PM
Hi, first time here and already apologizing that I can't put together the right search phrase for this...as i'm sure it's been covered.
i have an sql db table: logos_invoices, and two fields: `ticketz` and `datez`. I also have a form with text areas, 'ticket' and 'date'.
when the user enters the invoice # into the ticket field, I'd like for the correct date to automatically show up in date area, else null.

the code i'm trying looks something like this, but is not working..any ideas? am I on the right path?

if ('ticket' == $query = "SELECT * FROM ".$DBPrefix."invoices_ticketz") {
$query = "SELECT * FROM ".$DBPrefix. "invoices";
$result = mysql_query($query);
$system->check_mysql($result, $query, __LINE__, __FILE__);
$INVOICES = mysql_fetch_array($result);
'DATE' => $INVOICES ['datez'],

else ('DATE' == $null);

03-20-2009, 07:05 PM
welcome to CF.:thumbsup:

please post a create table statement so we can be sure that you have it OK too.

I think what you need is the INSERT IGNORE statement but I am not yet sure.


03-20-2009, 07:26 PM
hi bazz, thanks for welcome.

<!-- INCLUDE user_menu_header.html -->
<link href="style.css" rel="stylesheet" type="text/css" />
<style type="text/css">
body {
background-color: #FFF;
body,td,th {
font-size: 9px;
color: #000;
<form name="user_info" action="user_data.php" method="POST">
<table width="635" border="0">
<td><p><span class="titTable5"><strong>{L_27_002}</strong></span></p></td>
<td><input name="ticket" type="text" id="ticket" value="{TICKET}" />
*If applicable. Use numbers/letters only. </td>
<td><strong class="titTable5">{L_27_006}</strong></td>
<td class="titTable5"><input name="date" type="text" id="date" value="{DATE}" /></td>
<td height="23" valign="top">&nbsp;</td>
<td class="titTable6"><label>
<input type="submit" id="Submit" value="Submit" class="Button" />
<input type="reset" name="Cancel" id="Cancel" value="Cancel" class="Button" />
<!-- INCLUDE user_menu_footer.html -->

03-20-2009, 07:55 PM
oops, I shall explain better what I need.

something like :

create table table_name
( col1 int not null
, col2 varchar(nn) not null

if using phpMyAdmin try looking at the table and click on the export tab at the top. copy the text that shows up and post it here.


03-20-2009, 08:16 PM
oh yea sorry, should have read properly..thought u meant create form, lol. u see there's an ID lead off too. I'm obviously keeping some sensitive info out to avoid detection by skynet. :D .

CREATE TABLE IF NOT EXISTS `logos_invoices` (
`id` int(11) NOT NULL auto_increment,
`ticketz` int(32) NOT NULL default '0',
`datez` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,

03-22-2009, 03:23 AM
i think bazz went away for the weekend, lol. anyone got an idea?

03-22-2009, 03:33 AM
sorry :o

Currently I am away with the 'Havana Club' fairies :D

I should have said, I am not proficient in php so I don't actually understand your first-post query.

I had hoped that by showing your create table statement that I could have confirmed that you needed to set a default of 'timestamp' to the 'datez' column but, you are ahead of me on that because you had already done that.

I'll look again tomorrow and see if I can find some way to help.

but giong back to your create table statement; you do not need the (11) or the (32) in there. int on its own is fine, except when you use zerofilling, to append zeros to the front of the digits. eg 000000001. In that case int (9) would do it but as you have it, no number is required. jfyi.

At the risk of waffling on, I think this section of your post suggest you are looking for an ajax solution

when the user enters the invoice # into the ticket field, I'd like for the correct date to automatically show up in date area, else null.


03-22-2009, 03:44 AM
thanks man.
btw, careful, some of them fairies can be witch hagar in disguise, lol!!

03-22-2009, 03:48 AM
tell me about it. :D

on the updside, it tends to clear a load of crud from my brain and I can then code better for another while. a bit like a brain reset button. :confused:

Now I am not sure whether that means I am a code wizard or that I am crap. but I make progress afterwards anyway and I have (limited) fun on the way. :cool:


03-22-2009, 03:58 AM
any form of ascension makes the brain wiser :thumbsup:
we crossed posts, but, yea, I was thinking about ajax, but wanted to keep it simple for such a small thing. I had a variation where it actually did enter a date after filling invoice field, but it was the id#1 date regardless of what invoice# you entered...also it wouldn't go away after that. I'll check into it..if you think of anything, let me know...and enjoy the ride!!

Old Pedant
03-22-2009, 09:16 PM
Bazz: FYI. If you use some of MySQL's standard tools to dump out your DB tables, those *TOOLS* will put the INT(11) and so on into their output. Even if you didn't have them there in the first place.

I *think* it is mysqldump that does that, but I don't happen to have it here right now. But I remember using one of the tolls and being surprised at seeing that stuff appear. I never code like that, myself.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum