I have a website which has a form in it.
I am supposed to get the values from the form to put them in a database.
I am currently using razorCMS as a simple framework for my website and WEBMATRIX as the editor (i could use VS2010 but i wanna do that in webmatrix).
This is my form:
<form method="post" action="" class="custom">
<fieldset title="TITLE">
<legend>TITLE!</legend>
<div class="five columns">
<input type="text" placeholder="Pseudonimi" id="txtPseudo" value=""></input></div>
<div class="columns">
<select style="display: none;" id="jmSex">
<option selected>Don't know/option>
<option>M</option>
<option>F</option>
</select>
</div>
<div class="columns">
<select style="display: none;" id="jmCat">
<option selected>1</option>
<option>2</option>
<option>3</option>
</select>
</div>
<textarea id="jmNewText" rows="6" > </textarea>
<input class="radius button" id="btnAdd" type="Submit" title="Send" name="Dergo"
value="Send" style="float: right;" />
</fieldset>
</form>
After submitting my form i want to get the values using REQUEST, i am actually not getting any of the values. I get null variables all the time. I also tried to get the variables using JavaScript with document.getelementbyid(), i showes null.
This is my code on submit :
if (IsPost)
{
var pseudo = Request["txtPseudo"]; // THIS VALUE SHOWS NULL
var content = Request["jmTextNew"];
var kategori = Request["jmCat"];
var sex = Request["jmSex"];
var db = Database.Open("razorC");
var nextId = db.Execute("select max(id)+1 from rc_jm");
var sqlNew = "Insert INTO rc_Jm (pseudo, id, content, creation_date, kategori, sex) "
+ "values (@0, @4 , @1, GETDATE(), @2, @3)";
db.Execute(sqlNew, pseudo, content, kategori, sex, nextId);
}
Input values sent to the server identified by their
nameattribute not by theidattribute.So you need to give
nameto your inputs to be able to get them from theRequestSo
should be
etc.