Sponsored Content
Top Forums Web Development Php help to copy form field if empty Post 302918289 by barrydocks on Monday 22nd of September 2014 04:34:38 PM
Old 09-22-2014
Php help to copy form field if empty

I have an input form with several fields. What I would like to achieve is to auto populate or copy certain fields if they are empty when the form is submitted. I would like to use php if not then javascript but not jquery if possible - I have sort of had a go but I really have no idea Smilie

The bit of logic I need is:
If rNradd is empty then do nothing;
If rNradd and rVprism contain data and rNrVprism is empty then copy rVprism to rNrVprism;
If rNrVprism already contains data then do nothing.

There are a few other fields I need to do this for at the same time so I need the solution to be expandable.


Here is the section of code in question (written in DW - please do not be too derogatory):
Code:
 $insertSQL = sprintf("INSERT INTO spec_rx (spec_rx_id, FK_px_id, spec_rx_date, FK_user_id, spec_rx_rsph, spec_rx_rcyl, spec_rx_raxis, spec_rx_rhprism, spec_rx_rhprismbase, spec_rx_rvprism, spec_rx_rvprismbase, spec_rx_rnadd, spec_rx_rnhprism, spec_rx_rnhprismbase, spec_rx_rnvprism, spec_rx_rnvprismbase, spec_rx_rintadd, spec_rx_rinthprism, spec_rx_rinthprismbase, spec_rx_rintvprism, spec_rx_rintvprismbase, spec_rx_lsph, spec_rx_lcyl, spec_rx_laxis, spec_rx_lhprism, spec_rx_lhprismbase, spec_rx_lvprism, spec_rx_lvprismbase, spec_rx_lintadd, spec_rx_linthprism, spec_rx_linthprismbase, spec_rx_lintvprism, spec_rx_lintvprismbase, spec_rx_lnadd, spec_rx_lnhprism, spec_rx_lnhprismbase, spec_rx_lnvprism, spec_rx_lnvprismbase, ext_rx) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                       GetSQLValueString($_POST['SpecRxID'], "int"),
                       GetSQLValueString($_POST['pxID'], "int"),
                       GetSQLValueString($_POST['specRxDate'], "date"),
                       GetSQLValueString($_POST['userID'], "int"),
                       GetSQLValueString($_POST['rsph'], "double"),
                       GetSQLValueString($_POST['rcyl'], "double"),
                       GetSQLValueString($_POST['raxis'], "double"),
                       GetSQLValueString($_POST['rHprism'], "double"),
                       GetSQLValueString($_POST['rHprismbase'], "text"),
                       GetSQLValueString($_POST['rVprism'], "double"),
                       GetSQLValueString($_POST['rVprismbase'], "text"),
                       GetSQLValueString($_POST['rNradd'], "double"),
                       GetSQLValueString($_POST['rNrHprism'], "double"),
                       GetSQLValueString($_POST['rNrHprismbase'], "text"),
                       GetSQLValueString($_POST['rNrVprism'], "double"),

I have tried to add the following code without success:
Code:
    extract ($_POST);
    if (empty($_POST['$rNrVprism']) && !empty($_POST['$rNradd']) && !empty($_POST['$rVprism'])){
        $_POST['$rNrVprism'] = '$rVprism';
    }

I would really be grateful for some help Smilie
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Count of Field for Non-Empty

Hi Guys, I wanted to count the number of records for a particular field of a file. whose fields are separated by comma"," I fI use this command. cat "filename" cut -sd "," -f13 | wc -l This shows all the lines count including the blank values for the field number 13. I wanted to count... (2 Replies)
Discussion started by: Swapna173
2 Replies

2. Filesystems, Disks and Memory

DD copy excluding empty blocks?

I'm not 100% sure if this was the right place to post in but here i go: I'm attempting to migrate a physical windows disk onto my SAN through the use of the dd copy command. I'm booting into knoppix, running dd, and then bringing the server back up into windows running on the SAN. Everything... (2 Replies)
Discussion started by: Merkilo
2 Replies

3. Shell Programming and Scripting

Format the file by deleting empty field

I have the test data with 10 column separated by comma and each column has more than 1000000 rows. Can anyone help me to find empty field in all columns and delete that empty field alone and lift that column up by one row. Data with empty field: A74203XYZ,A21718XYZ,A72011XYZ,A41095XYZ,... (7 Replies)
Discussion started by: zooby
7 Replies

4. Shell Programming and Scripting

Converting form field to table format

May data Name = Andi Address = none Phone = 82728 Name = Peter Address = none Phone = 98799 The expected output Name,Address,Phone Andi,none,82728 Peter,none,98799 what i have done (6 Replies)
Discussion started by: before4
6 Replies

5. UNIX for Dummies Questions & Answers

remove empty field

Hi all ! I'm sure it is a basic question but I didn't find any threads that fit my need. How to remove empty fields with awk? Or in other words, how to shift all the fields after an empty field on the left? input: 1|2||3|4|5||6 wanted: 1|2|3|4|5|6 I tried: awk '{for(i=1; i<=NF;... (7 Replies)
Discussion started by: lucasvs
7 Replies

6. Shell Programming and Scripting

print non empty column/field value

I have below file 25-09-2012 24-09-2012 19-09-2012 31-07-2012 30-04-2012 30-03-2012 ASIAEXFVNV N/A CEU 4 DMIRSOA N/A CAS 2 2 2 DMIRSOA N/A MIDMT 2 NFIAL22 N/A HVNY 11 11 11 NFIAL22 N/A NYAL3 11 11 11 NFIAL22 N/A NYCN 11 11 11 ... (4 Replies)
Discussion started by: manas_ranjan
4 Replies

7. Shell Programming and Scripting

Copy last third char form string

HI Input A.txt ABC907 ABC907_1B_9 ABC985 ABC985_1A_9 ABC985 ABC985_1B_9 ABC985 ABC985_1C_9 ABC05037 ABC05037_1A_9 ABC05037 ABC05037_1B_9 Base of column 2 last third char. If It is A the 1,if B then 2 If C then 3 File B.txt ABC907 ABC907_1B_9 2 ABC985 ABC985_1A_9 1 ABC985... (8 Replies)
Discussion started by: asavaliya
8 Replies

8. Shell Programming and Scripting

How to detect empty field in awk ?

Hi ! programmers I have a need of detecting empty field in file my file looks like this 40.900|-71.600|1.6|20|1|1961|21.00|3.700||1|US|28035|10029370|31 40.900|-71.600|5.7|20|1|1961|21.00|3.700||1|US|28035|10029370|31 40.900|-71.600|7.8|20|1|1961|21.00|3.700||1|US|28035|10029370|31... (7 Replies)
Discussion started by: Dona Clara
7 Replies

9. Shell Programming and Scripting

Cgi to dump xml data from form input field

Hi All, I am trying to write a shell script which takes parse the web form find the input field and dump the data of that field into one xml file. The form looks like, <input type="button" id="btnSave" value="Save" onclick="saveXmlData()"/> <form name="submitForm"... (1 Reply)
Discussion started by: jdp
1 Replies

10. UNIX for Dummies Questions & Answers

Copy non-empty files into subdirectory

How to Copy non-empty files into subdirectory I have directory A there are bunch of files: a.txt a.txt.target b.txt b.target.txt....... How can i find out the non-empty file within *.txt.target and copy them into a subdirectory B? Thank you. (2 Replies)
Discussion started by: grace_shen
2 Replies
FORMS(3)						   BSD Library Functions Manual 						  FORMS(3)

NAME
field_count, form_fields, move_field, set_form_fields -- form library LIBRARY
Curses Form Library (libform, -lform) SYNOPSIS
#include <form.h> int field_count(FORM *form); FIELD ** form_fields(FORM *form); int move_field(FIELD *field, int frow, int fcol); int set_form_fields(FORM *form, FIELD **fields); DESCRIPTION
The field_count() function returns the number of fields that are attached to the given form, if the form argument passed is NULL then field_count() will return -1. The function form_fields() will return a pointer to array of attach fields for the given form, this array is not NULL terminated, fields may be attached to the given form by calling set_form_fields(). The fields argument in this function is a pointer to a NULL terminated array of fields that will be attached to the form. If there are already fields attached to the form then they will be detached before the new fields are attached. The new fields given must not be attached to any other form. The move_field() function will move the given field to the location specified by frow and fcol. RETURN VALUES
Functions returning pointers will return NULL if an error is detected. The functions that return an int will return one of the following error values: E_OK The function was successful. E_CONNECTED The field is connected to a form. E_POSTED The form is currently posted to the screen. E_BAD_ARGUMENT The function was passed a bad argument. SEE ALSO
curses(3), forms(3) NOTES
The header <form.h> automatically includes both <curses.h> and <eti.h>. BSD
January 1, 2001 BSD
All times are GMT -4. The time now is 03:14 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy