Classic ASP code inside HTML Form TextArea input return as text from Access database - forms

I want to insert with form TextArea input HTML with ASP code to Access 2000 database.
This is OK, but when retrieve the recordset from an ASP page, the part of ASP code is just text. What I'm doing wrong?
What I have tried:
The Insert Code:
<%
Set MM_editCmd = Server.CreateObject ("ADODB.Command")
MM_editCmd.ActiveConnection = MM_conn_STRING
MM_editCmd.CommandText = "INSERT INTO KioskLayout (KioskHtml) VALUES (?)"
MM_editCmd.Prepared = true
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param5", 203, 1, 536870910, Request.Form("KioskLayHtml")) ' adLongVarWChar
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close
%>
The HTML Form Code:
<form METHOD="POST" name="Layout" action="<%=MM_editAction%>" class="center">
<textarea class="form-control" id="KioskLayHtml" name="KioskLayHtml">
<!--This is The TextArea field Input -->
<div class="grid-container">
<div class="main"><%=rs("today")%></div>
<div class="Left"><%=rs("tomorrow")%></div>
<div class="Bottom"><%=rs("yesterday")%></div>
</div>
<!--End Of TextArea field Input -->
</textarea>
<input type="hidden" name="MM_insert" value="Layout">
<input type="submit" name="button" id="button" value="Submit">
</form>
But when retrieve the recordset from an ASP page shows this as text.
<%=rs("today")%>
<%=rs("tomorrow")%>
<%=rs("yesterday")%>
and view the page source shows this:
<div class="grid-container">
<div class="main"><%=rs("today")%></div>
<div class="Left"><%=rs("tomorrow")%></div>
<div class="Bottom"><%=rs("yesterday")%></div>
</div>
Any help?

IS the file saved as .ASP ? It appears to be pure HTML in which case what's between brackets won't be parsed on the server.

Related

How to debug the javascript inside a handlebars template in vscode?

I have some client-side javascript inside a handlebars template as follows :
customerloans.handlebars:
<h1> Form to view Upcoming loans for a customer </h1>
<div id="submitviewcustomerloansID">
<form action="/customerloans">
<label for="CustomerIdLoansForStyling"> Customer ID </label>
<input type="text" id="CustomerIdLoansForStyling" name="customerIDLoans">
<button type="submit"> Submit </button>
</form>
</div>
<div id="responseviewcustomerloansID"> </div>
<script>
document.getElementById('submitviewcustomerloansID')
.addEventListener('submit', evt => {
evt.preventDefault()
const form = evt.target
const body = JSON.stringify({
custID: form.elements.customerIDLoans.value
})
</script>
The browser is invoked from a node.js app
How can I put a breakpoint inside the javascript in VSCode ?
I have tried the instructions here but this does not seem to work for handlebars: https://www.youtube.com/watch?v=EXxbDVJ01wM

How to find data from multiple input fields on the server side (Express.js/Node.js)?

I have a form with multiple description text fields, file chose field and submit button for the Cross-Domain request (CORS variant):
<form class="upload" id="upload_form" enctype="multipart/form-data" method="post" action="http://localhost:3001/upload/1234567890">
<div class="row-fluid">
<div class="span5 row-fluid" id="description" style="margin-left:0px;">
<div>
<label>Title</label>
<input class="span12" type="text" placeholder="Title" id="description_title" name="description_title"/>
<label>Author</label>
<input class="span12" type="text" placeholder="Author" id="description_author" name="description_author"/>
<label>Tags</label>
<input class="span12" type="text" placeholder="Tags" id="description_tags" name="description_tags"/>
<label>Description</label>
<textarea class="span12" id="description_textarea" name="description_textarea" rows="5" style="resize:none"></textarea>
<div id="buttons" class="row-fluid" style="margin-top: 5px">
<div class="span12">
<span class="span5 btn btn-primary btn-file" id="chose_files_btn" onclick="filechose_button.click()">chose files
<input id="filechose_button" type="file" name="fileData" data-url="http://localhost:3001/upload/1234567890"/></span>
<button id="upload_button" type="submit" name="upload" class="span5 offset2 btn btn-success" disabled="true" onclick="$('#upload_form').trigger('upload_fired');">upload</button>
</div> <!-- span12 -->
</div> <!-- buttons -->
</div> <!-- well -->
</div> <!-- video_description -->
</div> <!-- row-fluid -->
</form>
The Node.js (Express.js) server has a route:
app.post('/upload/:id', function(req, res){
console.log(req.fields);
...
});
The problem is, I can not find the data from input fields: req.fields gets undefined.
How can I find the data (text description and a file) from the req on the server?
Update:
Great! req.body really get access to all the fields, BUT:
console.log(req.body)
prints:
{ description_title: 'aaa',
description_author: 'bbb',
description_tags: 'ccc',
description_textarea: 'ddd',
upload: '' }
but where is the fileData field? I mean, where the file I upload with the description (aforementioned fields)?
Update 2: Done!
Files are not in the body attribute, but in the req.files
Thanks for Adam and andyfan!
As said by Adam if you see these two lines
app.use(express.bodyParser());
app.use(express.methodOverride());
in app.js file of express, then you can read fields as given below.
app.post('/upload/:id', function(req, res){
console.log(req.body.description_title);
console.log(req.body.description_author);
console.log(req.body.description_tags);
console.log(req.body.description_textarea);
console.log(req.files);
res.send("Done!");
});
You can read more about how to handle files in express at this link http://howtonode.org/really-simple-file-uploads
You want req.body so long as you have express.methodOverride() in your configuration before the routes.
In your route try console.log(req.body); to see what object you get there. For the route parameters it is req.params.
console.log(object); can be your best friend when trying to find the objects your looking for and the data structure they are contained in.

Jquery selector seems not to work in google chrome

I want to update the value from a input/textfield with a calculated value from the cookie.It's like a mini local cookie cart.
Saving and retrieving the json from the cookie is a piece of cake.
In my behavior I fail to make the following work:
I added a class for every node in the input field, it's constructed like the example below.
Myid = 'webform_cart_nid_10';
formElement = $('.' + Myid);
console.log(formElement);
The html is quite nested and can be seen http://it2servu.be/broodjes/bestellen (if I may link?) .
the field whose value I want to update looks like this:
<input class="webform_cart_nid_10 webform_cart_nid form-text" type="text" id="edit-submitted-cart-item-cart-elements-10" name="submitted[cart_item][cart_elements][10]" value="0" size="3" maxlength="128">
Is contained in drupal output with severe div-itis.
<div class="page clearfix" id="page">
<div id="section-content" class="section section-content">
<div id="zone-content-wrapper" class="zone-wrapper zone-content-wrapper clearfix">
<div id="zone-content" class="zone zone-content clearfix container-12">
<div class="grid-12 region region-content" id="region-content">
<div class="region-inner region-content-inner">
<div class="block-inner clearfix">
<div class="content clearfix">
<div class="node node-webform node-promoted view-mode-full clearfix ">
<div class="field field-name-title field-type-ds field-label-hidden">
<form class="webform-client-form" enctype="multipart/form-data" action="/broodjes/bestellen" method="post" id="webform-client-form-5" accept-charset="UTF-8">
<div>
<fieldset class="collapsible form-wrapper collapse-processed" id="edit-submitted-cart-item-cart-elements">
<div class="fieldset-wrapper">
<div class="form-item form-type-textfield form-item-submitted-cart-item-cart-elements-10">
<input class="webform_cart_nid_10 webform_cart_nid form-text" type="text" id="edit-submitted-cart-item-cart-elements-10" name="submitted[cart_item][cart_elements][10]" value="0" size="3" maxlength="128">
...
probably it's something stupid, I just can't figure out what it is?
Your problem is with jQuery. If you pop open the console in Chrome and type jQuery, it returns the jQuery function. If you type $ it returns undefined. You have some sort of collision causing $ not to be set to jQuery.
use "jQuery" instead of "$"
Myid = 'webform_cart_nid_10';
formElement = jQuery('.' + Myid);
console.log(formElement);
the "$" never worked for me in Drupal 7.

One click to trigger several search forms?

I have 1 main search form with a submit button and several secondary search forms with submit buttons.
What I would like to do is when I enter text and click on the submit button of the main search form, the same text gets copied in all of the secondary search forms and all the submit buttons of the secondary search forms get automatically hit.
The HTML code for the mains earch form is shown below:
<form action="query.php" method="get">
Search: <input type="text" name="item" size="30">
<input type="submit" value="send">
</form>
One of the several secondary search forms is shown below:
<FORM action="http://www.dpbolvw.net/interactive" method="GET" target="_blank">
<div style="float: left; padding: 0 3px 0 0;">
<INPUT type="text" name="src" size="9"
value="<?php
$input = $_GET['item'];
echo $input;?>" style="width: 110px; height: 22px;margin:0; padding: 0; font-size:140%;">
</div>
<div style="float: left; padding: 0 3px 0 0;">
<input type="image" name="submit" value="GO" src="http://images.guitarcenter.com/Content/GC/banner/go.gif"
alt="Search" style="font-size:140%">
/div>
<input type="hidden" name="aid" value="1234"/>
<input type="hidden" name="pid" value="1234"/>
<input type="hidden" name="url" value="http://www.guitarcenter.com/Search/Default.aspx"/>
</form>
Notice the php code that I put in the "value" field of the secondary search form:
<?php
$input = $_GET['item'];
echo $input;?>
This automatically copies the text that I entered in the main search form into the secondary search form. I thus figured out how to do that.
The problem is to "simulate" an "Enter" keystroke or a click on the "GO" button with the mouse on the secondary search form when the user hits the Enter key or hits the "SEND" button with the mouse on the main search form.
Thank you for your insight!
I'm not sure what the point of that would be, It looks like all of these are search forms all pointing to different sites. Web browsers won't allow that. They can navigate to one page at a time. When you post a form to a page you are navigating to that page. Therefore, you are trying to navigate to several pages at once. It's like trying to be in Paris and London at the same time. I don't see how your plan will work the way you're describing it.
That said, You can use client-side javascript to call
document.forms[0].submit();
so if you can come up with a plan that does not involve trying to have the user see all the different search results in one window, you could try this on your first form...
<form action="query.php" method="get" onSubmit="document.forms(1).Submit();">
You should use AJAX (JQuery) as Brandon Suggested. Read http://docs.jquery.com/Events/submit
Example:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
$("#submit").click(function() {
//Do you stuff here like triggering other submits
//Like:
$("input#submit2").click();
$("input#submit3").click();
return false;
});
});
</script>
</head>
<body>
<form action="javascript:alert('success!');">
<div>
<input type="text" />
<input type="submit" id="submit" />
</div>
</form>
<form >
<div>
<input type="text" />
<input type="submit" id="submit2" />
</div>
</form>
<form >
<div>
<input type="text" />
<input type="submit" id="submit3" />
</div>
</form>
</body>
</html>
Take a look at the submit() event in jQuery. That is going to be your key.
I am assuming that you are planning on submitting via ajax? Otherwise it is futile.
So you could do something like this-
Give all of your forms a certain class, let's call it 'ajax_search_forms'. So now you can actually hook into the submit event.
$('.ajax_search_forms').submit(function(){
var search_string = $('input[name=src]').val();
$('.ajax_search_forms').each(function(){
$.ajax({
url : $(this).attr('action'),
data : 'search_string=' + search_string,
success : function(html){
// Do something with the result
}
});
});
// Return false is VERY important so that the form submission does not continue
return false;
});

Facebook form post data not present on backend

I am attempting to post form data to my app using Facebook. My form is integrated with a dialog and I am using form.submit() to submit the form. Please see my code. The post data does not appear on the backend (e.g. load-cargo-radio, city-id, train-id), but the fb_sig* data does. Does anyone know if there are any caveats regarding posting form data with Facebook? Thanks!
Note: I have tried both using my server domain and my fb callback url for the form action. Neither works.
<div id="action_prompt">
Loading cargo...
</div>
<fb:js_string var="fbjs_load_cargo_select">
<div id="load_cargo_select">
<form id="load_cargo_select_form" action="http://railsacrosseurope.com/turn/load_cargo_select" method="POST">
<p>Your train has stopped in the city of Arhus.</p>
<p>Arhus produces the following goods:</p>
<ul>
<li>Dairy</li>
</ul>
<p>Your train is hauling the following goods:</p>
<ul>
<li>Timber</li>
</ul>
<p>What would you like to do?</p>
<input type="radio" id="load_cargo_radio" value="1">Load new goods</input>
<input type="radio" id="load_cargo_radio" value="2">Discard existing goods</input>
<input type="hidden" id="city_id" value="3" />
<input type="hidden" id="train_id" value="15" />
<input type="submit" id="submit" value="Submit" />
</form>
</div>
</fb:js_string>
.
.
.
<script type="text/javascript">
var dialog = new Dialog().showChoice('Load Cargo', fbjs_load_cargo_select, 'Okay', 'Pass');
dialog.onconfirm = function() {
// Submit the form if it exists, then hide the dialog.
frm = document.getElementById('load_cargo_select_form');
if (frm) { frm.submit(); }
dialog.hide();
};
dialog.oncancel = function() {
form = document.getElementById('redirect_form');
form.setAction('http://apps.facebook.com/rails_across_europe/turn/move_trains_auto/');
form.submit();
}
</script>
[/code]
The problem was not with Facebook. The problem was that I left out the "name" attribute for my input elements.