How to append a tbody after removing tbody using jquery? - jquery-ui-dialog

if ($("#ddlRateCode").next().val() != "MYKL GROSS") {
$("#compRecord tbody").remove();
$("#compRecord tbody").append("<tr class='compensationRecords'>" +
"<td class='tdCompRateCode table_td'>" + $("#ddlRateCode").next().val() + "</td>" +
"<td class='tdCompRate table_td'>" + $("#txtCompRate").val() + "</td>" +
"<td class='tdCompPercent table_td'>" + $("#txtCompPercent").val() + "</td>" +
"<input type='hidden' value='" + $("#ddlRateCode").val() + "' class='tdRateCodeId' />" +
"<td class='table_td'><button class='edit'>Edit</button>" +
"<button class='btnDelete'>Delete</button></td>" +
"</tr>");
}

$("#compRecord").append("<tbody><tr>...</tr></tbody>");
If that is not what you are looking for, you'll need to describe your problem better. Just the question in the head and some random code without explanation isn't a good question.

Related

Controlling the space between <p> elements in a table

Lets say I have a table:
"<table border=1>" +
"<tr width=100%>" +
"<th width=50% align='left'><b>Adapted Preliminary Flood Hazard Information</b>" +
"</tr>" +
"<tr width=100%>" +
"<td id='small-lines' width=20%><p>What is <span class='tooltip'>Adapted Preliminary’" + popup1 + "</span> Hazard Information?</p>" +
"<p><span class='tooltip'>What is my property's flood zone’" + popup2 + "</span> <b>" + graphic.attributes.EFF_FLD_ZN + "</b></p>" +
"<p><span class='tooltip'>What is my property's Post-Storm 1% Elevation’" + popup3 + "</span> <b>" + graphic.attributes.str_con_LPE + " - " + graphic.attributes.str_con_HPE + "</b></p>" +
"<p><span class='tooltip'>Whats my property's Post-Storm 0.2% Elevation’" + popup4 + "</span> <b>" + graphic.attributes.str_con_LPE + "</b></p>" +
"<p><span class='tooltip'>What is my property's observed storm elevation’" + popup5 + "</span> <b>" + graphic.attributes.str_con_HPE + "</b></p>" +
"<p><span class='tooltip'>Was there erosion on my property based on the event’" + popup6 + "</span> <b>Yes</b></p>" +
"<p><span class='tooltip'>Is my property within a 30 year erosion risk area’" + popup8 + "</span> <b>" + graphic.attributes.PARCELID + "</b></p>" +
"<p><span class='tooltip'>Is my property within a 60 year erosion risk area’" + popup9 + "</span> <b>" + graphic.attributes.PARCELID + "</b></p>" +
"<p><span class='tooltip'>View your property's Storm Event Elevation on our <a href='http://portal.nwfwmdfloodmaps.com/' class='tooltip'>Event Web Viewer." + popup10 + "</a></p>" +
"<p>Where can I get <a href='http://portal.nwfwmdfloodmaps.com/' class='tooltip'>GIS Data" + popup11 + "</a> for my property area’</p>" +
"<p></p>" +
"</td > " +
"</tr>" +
"</table>"
The table looks like this:
Lets say I want to control the amount of space between each <p>. Maybe I want to make them tighter together. I assume I need some CSS but I am not sure how to correctly apply it to tighten the space between the default line breaks in my <p> paragraphs. Any suggestions?
use:
p { margin:0 }
This will make them tighten
What is CSS Margin? Click here
You could use p { margin: 5px 0; } where 5px is whatever you actually want the space between paragraphs to be. (First number specifies top/bottom margins, the second specifies left/right margins.)

Data from Firebase in Browser shows fine but in html page shows as undefined

I have data downloaded from firebase DB and the data is fine but when this data is loaded into HTML all table TD shows undefined, not able to understand why been check a whole lot of codes not able to understand whats wrong here.
Thank You
var registration = firebase.database().ref("REGISTRATION")
dataRef = firebase.database().ref().child("REGISTRATION");
dataRef.on("value", rData);
function rData(data){
console.log(data.val());
var gData = data.val();
for (gDatarow in gData)
{
alert(email);
var email = gDatarow.email;
var name = gDatarow.name;
var gender = gDatarow.gender;
var date = gDatarow.date;
var phone = gDatarow.phone;
var state = gDatarow.state;
var school = gDatarow.school;
var clas = gDatarow.clas;
var classname = gDatarow.classname;
$("#reData").append("<tr><td>" + email + "</td></td>" + name + "</td><td>" + gender + "</td></td>" + date + "</td><td>" + phone + "</td></td>" + state + "</td><td>" + school + "</td></td>" + clas + "</td><td>" + classname + "</td></tr>");
}
}
enter image description here
This is what worked in my case :
dataRef.on("child_added", function(data) {
var rData = data.val();
$("#reData").append("<tr><td>" + rData.email + "</td><td>" + rData.name + "</td><td>" + rData.gender + "</td><td>" + rData.birthdate + "</td><td>" + rData.phone + "</td><td>" + rData.state + "</td><td>" + rData.school + "</td><td>" + rData.class + "</td><td>" + rData.classname + "</td></tr>");
});
Thanks to all for their time.

Forward Slash is removed in path

I have set the html from code behind in ItemDataBound event of repeater but in html path is not right.
Dim video_path = imgUrl + VideoPath + VideoName.split(".")(0) + ".mp4"
Dim poster_path = imgUrl + VideoPath + VideoName.split(".")(0) + ".png"
Dim DvVidContent As HtmlContainerControl = CType(e.Item.FindControl("DvVidContent"), HtmlContainerControl)
Dim onclick = "'ShowVideoDialog('size_vp_" + count.ToString() + "', '" + video_path.ToString().Trim() + "');'"
Dim Header As String = "<div style='position:relative;' Sequence='" + count.ToString() + "' id='" + ID.ToString() + "' class='SessionFolderViewChild'><img onerror='handleError(this);' src='" + poster_path.ToString() + "' alt='Thumbnail'/><img class='dv_play_icon' onclick='" + onclick + "' id='PlayVideo' style='position:absolute;top:8px;left:26px;height:100px;width:100px;' src='../../Images/icn_Play.png'/></a></div>"
DvVidContent.InnerHtml = Header.Trim()
count = count +
After Html rendering its remove the forward slash and look like
onclick="ShowVideoDialog("size_vp_1','.. .. resources sbs attachments steps351 step565 130906720751358852.mp4');

incorrect syntax near the keyword 'Values'

this is my code.i want to save these values into database.And an error occured,
incorrect syntax near the keyword Values
foreach (GridViewRow gvr in GridView1.Rows)
{
string strcon1;
strcon1 = ConfigurationManager.ConnectionStrings["fwma_devConnectionString"].ConnectionString;
SqlConnection con1 = new SqlConnection(strcon1);
con1.Open();
SqlCommand com3 = new SqlCommand(strcon);
TextBox tb = (TextBox)gvr.FindControl("TextBox2");//value
string txt = tb.Text;
Label propertylabel = (Label)gvr.FindControl("Label4");//id-property
com3.CommandText = "INSERT INTO BrandProperties(PropertyID,BrandID,Values) values(" + propertylabel.Text + "," + B_id.Text + "," + tb.Text + " ), con1";
com3.Connection = con1;
com3.ExecuteNonQuery();
con1.Close();
use this
com3.CommandText = "INSERT INTO BrandProperties(PropertyID,BrandID,Values) values('" + propertylabel.Text + "','" + B_id.Text + "','" + tb.Text + "')";
instead of
com3.CommandText = "INSERT INTO BrandProperties(PropertyID,BrandID,Values) values(" + propertylabel.Text + "," + B_id.Text + "," + tb.Text + " ), con1";
If you are using the reserved keywords ,you should specify delimited identifiers either quoted or bracketed.
example using bracketed
com3.CommandText = "INSERT INTO BrandProperties(PropertyID,BrandID,[Values]) values(" + propertylabel.Text + "," + B_id.Text + "," + tb.Text + " ), con1";
Shouldn't this line be like this?
com3.CommandText = "INSERT INTO BrandProperties(PropertyID,BrandID,Values) values(" + propertylabel.Text + "," + B_id.Text + "," + tb.Text + ")";
and please use command parameters:
When should "SqlDbType" and "size" be used when adding SqlCommand Parameters?

System.Data.SqlClient.SqlException: Incorrect syntax near ''

cmd.Connection = con;
con.Open();
cmd.CommandText = "Update tiit.Enquiry Set Status='" + DropDownList4.SelectedValue + "', NextFollowup='" + TextBox8.Text + "', Remarks='" + TextBox9.Text + "', Name='" + TextBox1.Text + "', Email='" + TextBox2.Text + "', Phone='" + TextBox3.Text + "','','','','', City='" + TextBox4.Text + "', Country='" + TextBox5.Text + "', Course='" + TextBox6.Text + "', Comments='" + TextBox7.Text + "', Cost='" +TextBox14.Text+ "' where SN='" + HiddenField1.Value + "'";
int i = cmd.ExecuteNonQuery();
con.Close();
No, don't do this. Never use string concatenations (+ operator) when building your SQL queries. Use parametrized queries:
cmd.Connection = con;
con.Open();
cmd.CommandText = "UPDATE tiit.Enquiry Set Status=#Status, NextFollowup=#NextFollowup, ...";
cmd.Parameters.AddWithValue("#Status", DropDownList4.SelectedValue);
cmd.Parameters.AddWithValue("#NextFollowup", TextBox8.Text);
...
This way your code won't be vulnerable to SQL injection and you won't have any encoding problems.
In all probability this:
"Update tiit.Enquiry Set Status='"
is you problem. (I'm talking about the .)
I completely agree however - use parametrised queries.

Resources