Need Help to get value of selected item from Select Dropdown list in cfquery under insert query - coldfusion-9

Form:
<!-- Sign up FORM -->
<cfoutput>
<form method="post" action="HomeShow_submit.cfm">
<input type="hidden" name="UserID" value="#RemoveChars(CGI.Auth_User, 1, Find('\', CGI.Auth_User))#">
<input type="hidden" name="Fname" value="#User.fname#">
<input type="hidden" name="Lname" value="#User.lname#">
<input type="hidden" name="Year" value="#DatePart('yyyy', Now())#">
<table width="600" border="0" align="center" cellpadding="1" cellspacing="1">
<tr>
<th colspan="2" scope="col" class="Header" align="center">Home Show Sign Up Form</th>
</tr>
<tr>
<th align="left" class="red">Shifts</th>
<td><select name="ShiftsList">
<option value="" selected> ... select a Shift</option>
<cfloop query="ShiftsList">
<option value="#ShiftsList.ShiftDetails#">#ShiftsList.ShiftDetails#</option>
</cfloop>
</select>
</td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" NAME="SubmitForm" value="Submit"></td>
</tr>
</table>
</form>
</cfoutput>
ActionPage
<cfquerydatasource="HomeShow" name="InsertHomeShow">
INSERT INTO HomeShow
(UserID,
Fname,
Lname,
Year,
ShiftID
)
VALUES
('#Form.USERID#',
'#Form.Fname#',
'#Form.Lname#',
'#Form.Year#'
?
)
</cfquery>
Question: This is where I need help, suppose we choose option with value =1 i.e. Friday March 20th 10.00 a.m to noon. I want to get value i.e 1 in Insert statement. So What I can write in side Insert statement to get that value.

Got it! Some suggestion helped me a lot finding the answer!!!
<!--Form -->
<tr>
<th align="left" class="red">Shifts</th>
<td><select name="ShiftsID"> <cfloop query="ShiftsList">
<optio value="#ShiftsList.ShiftID#">#ShiftsList.ShiftDetails#</option>
</cfloop>
</select>
</td>
</tr>
<!-- Actionpage-->
<cfquery datasource="HomeShow" name="InsertHomeShow">
INSERT INTO HomeShow
(UserID,
Fname,
Lname,
Year,
ShiftID
)
VALUES
('#Form.USERID#',
'#Form.Fname#',
'#Form.Lname#',
'#Form.Year#',
'#Form.ShiftsID#'
)

Related

Adding breaks in table td

<div id="headerAgentInfoDetailsPhone">
<table>
<tr>
<td>vendor:</td><td><input type="text" /></td>
<td>vendorgroup:</td><td><input type="text" /></td>
<td>account:</td><td><input type="text" /></td>
</tr>
I have code as above. Now I want a break function after the second td. For example as follows:
<div id="headerAgentInfoDetailsPhone">
<table>
<tr>
<td>vendor:</td><td><input type="text" /></td><br />
<td>vendorgroup:</td><td><input type="text" /></td><br />
<td>account:</td><td><input type="text" /></td>
</tr>
I tried to add td:n-thchild(even):after {content: \A; white-space: pre;
text-align: justify;} but its not working. The whole content is getting displayed in a single row.
A <br /> between a </td> and a <td> cannot do anything. What do you want to do by "adding a break" ?
If you want to show each info on a separated line, you have to write a new <tr> :
<table>
<tr>
<td>vendor:</td><td><input type="text" /></td>
</tr>
<tr>
<td>vendorgroup:</td><td><input type="text" /></td>
</tr>
<tr>
<td>account:</td><td><input type="text" /></td>
</tr>
</table>
It will draw a 3 lines table, with 2 cells in each line.
Yes, <tr is table row, and <td is table data. See http://www.w3schools.com/html/html_tables.asp for explanation. In a table you can't break the row with <br>, so if you use </tr> and <tr> to start a new table row instead it will work better.

POST request not working in form

I'm trying to submit some form using POST method. Here is par of form:
<form action="interlopers.php" mehod="post" id = "interlopersForm" name="interlopersForm" onsubmit="return validateInterlopersForm()">
<table border="0">
<tr>
<td> <label for="ast_num" > Ast. num </label> </td>
<td> <input type="text" name="ast_num" id = "ast_num"
value="<?php if(isset($_REQUEST['ast_num'])) { echo htmlentities ($_REQUEST['ast_num']); } ?>"
size="6"> </td>
</tr>
<tr>
<td><label for="cut_off"> Cut-off </label></td>
<td><input type="text" name="cut_off" id="cut_off" size="6" ></td>
</tr>
<tr>
<td><label for="data"> Data </label></td>
<td><input type ="checkbox" name="data" id = "dataSDSS" value="SDSS" checked> SDSS <br>
<input type ="checkbox" name="data" id="dataWISE" value="WISE" checked > WISE <br>
<input type ="checkbox" name="data" id = "dataSp" value="Sp" checked> Taxonomy</td>
</tr>
<tr>
<td> <label for="isFinalStep"> Just interlopers? </label> </td>
<td> <input type = "checkbox" name="isFinalStep" id = "isFinalStep"> </td>
</tr>
<tr> <input type="hidden" name="submitted" value="1"> </tr>
<tr>
<td colspan="2" align="center"> <input type="submit" value="Calculate" > </td>
</tr>
</table>
</form>
But, instead of getting POST request im getting GET request. I'm using apache server and php5 on Ubuntu. I tried this on local-server and on remote host, but still GET instead of POST.
Change mehod="post" to method="post".
You wrote wrong.

click on a checkbox selenium java

Hi, I want to b able to click on a check box based on a value. Below is the html of the same:
<tbody>
<tr>
<th>Record Type</th>
<th style="text-align:center">Has Access?</th>
<th style="text-align:center">Can Create?</th>
<th style="text-align:center">Can Read All Records?</th>
</tr>
<tr>
<td>
<input id="ORMW.S2.0.Object Type" class="readOnlyField" type="text" value="Account" maxlength="255" size="25" name="ORMW.S2.0.Object Type" readonly="readonly"/>
</td>
<td align="center">
<input id="ORMW.S2.0.Has Access_VP123456" type="checkbox" onclick="cbValue(this,'ORMW.S2.0.Has\x20Access');" style="margin-left:0px;margin-top:1px;height:10px;width:10px;vertical-align:middle"/>
<input id="ORMW.S2.0.Has Access" type="hidden" value="Y" tabindex="-1" name="ORMW.S2.0.Has Access"/>
</td>
<td align="center">
<td align="center">
I want to click on checkbox based on the value account here.
Next query will search element by #value='Account' then traverse up to the first tr and then search your checkbox:
//input[#type='text' and #value='Account']/ancestor::tr[1]//input[#type='checkbox']
you can also try this:
//input[#type='checkbox' and preceding-sibling::input[#type='text' and #value='Account']]

Clicking on checkbox based on tables column value - IE Webdriver Selenium

Clicking on checkbox based on tables column value using Xpath. Below is the html
<table id="tblHotels">
<TBODY>
<TR>
<TH align="left">
<INPUT checkbox="" id="chkNSelectAll name=chkNSelectAll type="/>
</TH>
<TH align="left" title="Hotel">Hotel</TH>
<TH title=" align=left">
<SPAN id="spnExpandBtn">
<IMG/>
</SPAN>
</TH>
<TH align="left" title="Hotel">Hotel</TH>
<TH align="left" title="Reg Date">Reg Date</TH>
<TH align="left" title="Room Type">Room Type</TH>
<TH align="left" title="Location">Location</TH>
<TH align="left" title="Room Number">Room Number</TH>
</TR>
<TR>
<TD colSpan="11">
<IMG src=" ../NoExpiry/images/uaimBSpacer.gif"/>
</TD>
</TR>
<TR>
<TD>
<INPUT id="chkNSelect" name="chkNSelect" type="checkbox" value="on"/>
</TD>
<TD customHiddenText="">MATHEW Joe</TD>
<TD/>
<TD customHiddenText="">
<SPAN>Affray (
<STRONG/>Kim Lee)
</SPAN>
</TD>
<TD class="regDate customHiddenText=">10/01/2014</TD>
<TD customHiddenText="">1HE</TD>
<TD customHiddenText="">South West </TD>
<TD id="tdChildroom name=" tdChildroom=""/>
<INPUT id="hidYID" name="hidYID" type="hidden" value="409">
<INPUT id="hidYD" name="hidYD" type="hidden">
<INPUT id="hidYDID" name="hidYDID" type="hidden" value="1015389"/>
</INPUT>
</INPUT>
</TR>
<TR>
<TD>
<INPUT id="chkNSelect" name="chkNSelect" type="checkbox" value="on"/>
</TD>
<TD customHiddenText="">MATHEW Penny</TD>
<TD/>
<TD customHiddenText="">
<SPAN>Affray (
<STRONG/>Jim Lee)
</SPAN>
</TD>
<TD class="regDate customHiddenText=">10/01/2014</TD>
<TD customHiddenText="">1HE</TD>
<TD customHiddenText="">South West </TD>
<TD id="tdChildroom name=" tdChildroom=""/>
<INPUT id="hidYID" name="hidYID" type="hidden" value="409">
<INPUT id="hidYD" name="hidYD" type="hidden">
<INPUT id="hidYDID" name="hidYDID" type="hidden" value="1015389"/>
</INPUT>
</INPUT>
</TR>
</TBODY>
</table>
here is what i am trying and this always clicks the first checkbox??
Driver.FindElementByXPath("//td[contains(text(),'MATHEW Penny')]/preceding::td/input[#name='chkNSelect']").Click()
If i try to just find the column with the text it can find it not why it cannot find the preceding check box and jumps to first rows check box??
Driver.FindElementByXPath("//td[contains(text(),'MATHEW Penny')]
my requirement is to select the first checkbox (do something eg:add it to another table) uncheck it then check the 2nd checkbox (do something eg:add it to another table).
Use for MATHEW Penny:
//td[contains(text(),'Penny')]/preceding-sibling::td/input[#name='chkNSelect']
Use for MATHEW Joe:
//td[contains(text(),'Joe')]/preceding-sibling::td/input[#name='chkNSelect']
Its selecting all input elements with name as chkNSelect which comes before td with text as MATHEW Penny.
Use
//td[contains(text(),'MATHEW Penny')]/preceding::td/input[last()][#name='chkNSelect']
to select only first such input
You could try:
first targeting the tr
containing the td with the text node you want (using a predicate)
and then going to an input within a td in that table row
So that translates to:
Driver.FindElementByXPath("//tr[td[contains(text(),'MATHEW Penny')]]/td/input[#name='chkNSelect']")
Breakdown:
//tr[
td[
contains(text(),'MATHEW Penny')
]
]
/td/input[#name='chkNSelect']

CFFILE upload - insert file location into SQL db at the same time?

I have a little page that has a form with a few fields in it. Also included is a file upload function. I need to be able to have the filename of the file being uploaded to be inserted into the 'sURL' field, when the form is submitted. (The sURL field can be populated automatically with this filename or can also be manually entered if it is an external URL). I have looked at other people with this issue and there seems to be no straightforward fix? Is anyone able to shed some light?
<html><head>
<title>New Survey Entry</title>
</head>
<body>
<script language="JavaScript" type="text/javascript">
function check ( form )
{
if (form.ul_path.value == "") {
alert( "Please select the file to upload." );
form.ul_path.focus();
return false ;
}
return true ;
}
</script>
<CFIF NOT isDefined("dir")>
<CFSET dir = "">
</CFIF>
<CFIF NOT isDefined("clientFile")>
<CFSET clientFile = "">
</CFIF>
<CFQUERY NAME="getpub" DATASOURCE="testpage" DBTYPE="ODBC">
SELECT *
FROM surveypubs
ORDER BY sGroup asc
</CFQUERY>
<h2><center>NEW SURVEY ENTRY</center></h2>
<table cellpadding="3" cellspacing="3" class="font13">
<cfoutput>
<form name="input" enctype="multipart/form-data" action="index.cfml?cat=test&page=insertSurvey" method="post">
<tr>
<td valign="middle" align="left"><b>Year:</b></td>
<td colspan="3"><input name="sYear" type="text" size="8" value="<CFOUTPUT>#year(now())#</CFOUTPUT>"><input name="sYear_required" type="hidden" value="You must enter a Year."></td>
</tr>
</cfoutput>
<tr>
<td valign="middle" align="left"><b>Group:</b></td>
<td colspan="3"> <select name="sGroup">
<option value="">--- Select One ---</option>
<cfoutput query="getpub"><option value="#sGroup#">#sGroup#</option></cfoutput>
</select> <br> Don't see the Survey Group? Click here to add.
</td>
</div><br><br>
</tr>
<tr>
<td valign="middle" align="left"><b>Title:</b></td>
<td colspan="3"><input name="sTitle" type="text" size="85"><input name="sTitle_required" type="hidden" value="You must enter a Title."></td>
</tr>
<tr>
<td valign="middle" align="left"><b>Comment:</b></td>
<td colspan="3"><input name="sComment" type="text" size="85"></td>
</tr>
<tr>
<td valign="middle" align="left"><b>URL:</b></td>
<td colspan="3"><input name="sURL" type="text" size="85"></td>
</tr>
<td valign="bottom" align="left"><b>URL Type:</b></td>
<td colspan="3">
<input type="radio" name="surlType" value="0" checked> Internal <input type="radio" name="surlType" value="1"> External</td>
</tr>
<cfoutput>
<input name="dateAdded" type="hidden" value="#dateformat(now(),"mm-dd-yyyy")#">
</cfoutput>
<tr>
<td></td>
<form action="/index.cfml?cat=test&page=inputSurvey" method="POST" enctype="multipart/form-data" name="upload_form" id="upload_form" onsubmit="return check(this);">
<CFIF structKeyExists(form, "ul_path") and len(form["ul_path"])>
<CFFILE ACTION="UPLOAD" FILEFIELD="ul_path" DESTINATION="D:\testpage\docs\" NAMECONFLICT="OverWrite">
<CFSET ClientFilePath = "#clientDirectory#\#clientFile#">
</CFIF>
<td colspan="3" align="left">Click on the Browse button to select the file to Upload:<br>
<input type="file" name="ul_path" id="ul_path" style="height: 22px;width: 350px;" value=""></td>
</tr>
<tr>
<td></td>
<td colspan="3" align="center"><input type="submit" name="submit" value="Submit"> <input name="clear" value="Clear" type="reset"> <input type="button" name="back" value="Back" class="input" onClick="javascript:history.back();"></td>
</tr>
</table>
</form>
<cfif isDefined("CFFILE.ClientFile")>
<cfset form.sURL = "#CFFILE.ClientFile#">
<cfelse>
<cfset form.sURL = "null">
</cfif>
<cfoutput><input type="hidden" name="sURL" id="sURL" value="http://testpage.com/docs/#ClientFile#"/></cfoutput>
</form>
</body>
</html>
Use the result attribute of cffile, this will then give you a structure of data about your upload, including the directory the file was stored in as well as the file name. Add result='moo' to your cffile call and then do a cfdump of moo to see all the data.
Check out this link for more info on what is returned in result
I sense that what you are trying to do is not being answered here. What you seem to be trying to do is on the client before the file is uploaded. You wish to collect the name of the file the user has chosen from his or her file system and using JS populate some other form field - which may contain the name of the file or possible some URL value or something else provided by the user.
That's different from collecting the name of the form after it is submitted because it runs afoul of browser protections. I really don't think there's an adequate solution in JS to this. You might find a solution that works in some browsers but I doubt it will be consistent.
I could be wrong of course. I'd be glad to have someone show me a solution.