|
In JavaScript? That's not possible for security reasons. If it would be possible, then websites could easily delete files on your system, which is probably not what you want. So no, it's impossible.
|
|
|
|
|
Hi I have a SQL Server Table named News with the following
columns-id,Title,Body,Created datetime and
Inside It's a column 'Number of clicks'.
Now I want to increment it by 1 when the title of a particular news is clicked.I need the c# code.Help, i can't do it
|
|
|
|
|
Don't post the same question in multiple forums.
Also, this question has nothing to do with javascript.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Ive tried to do something with the click thing. that u could only reserve from the seatmap depends of quantity of tickets u bought. I dont have whenever i click a seat it always get the original value that it fetched from the line 3.
<script>
$(document).ready(function(){
var qty = $("#qty").val();
var hasBeenClicked = false;
jQuery('.a-seats').click(function(){
qty--;
});
if(qty == 0){
document.getElementById("a-seats").style.zIndex='-1';
}
});
</script>
|
|
|
|
|
Move this :
var qty = $("#qty").val();
to
jQuery('.a-seats').click(function(){
qty = $("#qty").val();
qty--;
});
|
|
|
|
|
Hello ive tried it but it also doesnt work.
here is the new code
<script>
$(document).ready(function(){
jQuery('.a-seats').click(function(){
qty = $("#qty").val();
qty--;
});
if(qty == 0){
document.getElementById("a-seats").style.zIndex='-1';
}
});
</script>
|
|
|
|
|
What did not work, be more specific. Did you include jquery library in the header? Do you have an element with class='a-seats'? Can you show the other code?
|
|
|
|
|
I used ajax for this query and for the seatmap and had a header onto the seatmap main file, the code below are the few code which is like a function that will be printed out in a div in seatmap main file.
<script>
$(document).ready(function(){
jQuery('.a-seats').click(function(){
qty = $("#qty").val();
qty--;
});
if(qty == 0){
document.getElementById("a-seats").style.zIndex='-1';
}
});
</script>
<?php
$db = mysqli_connect('localhost','root','','capstone');
$getallmsg = "SELECT * FROM reservation where seatColumn = 'A' ORDER BY Id DESC"; //ORDER BY seatId DESC
$result = $db->query($getallmsg);
echo '<div id="a-holder">';
while ($holder = $result->fetch_array(MYSQLI_ASSOC)) {
$template = '<div class="a-seats" id="%s"></div>';
$id= $holder['seatId'];
$reserved = $holder['reserved'];
printf("$template ",$id);
?>
<?php
}
echo '</div>';
/*free result set */
$result->free();
/* close connection */
$db->close();
?>
|
|
|
|
|
As far as I can see:
1. There is no inclusion of jquery library;
2. There is no element with id='qty'.
Suggest you take a look some jQuery examples: jquery_selectors[^]
|
|
|
|
|
but i have inclusion from its parent.
ohh ive deleted it
<?php
$qty = $_POST['qty'];
echo '<input type="hidden" id="qty" value="'.$qty.'">';
?>
<script>
$(document).ready(function(){
qty = $("#qty").val();
jQuery('.a-seats').click(function(){
if(qty != 0){
alert(qty);
qty--;
}else if(qty == 0){
document.getElementByClass("a-seats").style.zIndex='-1';
}
})
});
</script>
nothing changed..
|
|
|
|
|
hello, as u can see i put an alert(qty); but whenever i clicked the button it popped out the same value of qty and will not decrement nor increment.
|
|
|
|
|
By the way, this is the script where the seatmap is being called.
is it because i got setInterval thats why my increment or decrement doesnt work properly?
<script>
var timer = 0;
$(document).ready(function() {
var from = $("#holder_from").val();
var destination = $("#holder_to").val();
var qty = $("#holder_qty").val()
timer = setInterval(function() {
$.ajax({
type : "POST",
url : "select_seatmap.php",
data : "from="+from+"&destination="+destination+"&qty="+qty,
success : function(data) {
$('#seatmap-wrapper').html(data);
}
});
}, 500);
})
</script>
|
|
|
|
|
Hello i think the problem when getting the value from qty is from this.
<script>
var timer = 0;
$(document).ready(function() {
var from = $("#holder_from").val();
var destination = $("#holder_to").val();
var qty = $("#holder_qty").val()
timer = setInterval(function() {
$.ajax({
type : "POST",
url : "select_seatmap.php",
data : "from="+from+"&destination="+destination+"&qty="+qty,
success : function(data) {
$('#seatmap-wrapper').html(data);
}
});
}, 1000);
})
</script>
Using the setinterval as a 1000 milliseconds finish it is like renewing the current last value of the qty which is in here.
<?php
$qty = $_POST['qty'];
echo '<input type="hidden" id="qty" value="'.$qty.'">';
?>
<script>
$(document).ready(function(){
var qty = parseInt($("#qty").val());
jQuery('.a-seats').click(function(){
clearInterval(timer);
if(qty != 0){
qty--;
}
if(qty == 0){
$('.a-seats').unbind();
}
})
});
</script>
becuase of the interval, even before the user/customer finished his/her events, the qty would continuously get data with the post method. am i right? uhmm if ever i got the point, what ways do to make unbind run not being in the setInterval. because unbind could run depends on qty value and removing setInterval it works properly but the query or the seatmap will not update realtime unless u refresh the page. Sorry for my english. Thanks in advance
|
|
|
|
|
Hi all,
I know that normally one can add string(s) to an array upon declaring the array by placing the string or strings inside the parenthesis, surrounded by double quotes and separating them with a comma. However, I would like to dynamically add them by doing the following but I cannot get it to work:
var stringArray[] = new Array(3);
vary string1 = "First";
vary string2 = "Second";
vary string3 = "Third";
for(x=0; x<stringArray.length-1; x ++)
{
stringArray[x]= "string" + x+1;
}
Please explain why the code above does not work, in detail thanks.
modified 17-Jan-14 21:23pm.
|
|
|
|
|
Your first line contains a syntax error, so none of the code will execute. You don't need the square brackets when you declare an array in Javascript (I think you do in Java, but it's been years since I did any).
var stringArray = new Array(3);
Apart from that, you have "vary" instead of "var" for your three strings, and you are terminating the loop one item too early.
To use the actual string variables you declared, you have to eval the string you create using the loop index like this:
stringArray[x] = eval("string" + (x + 1));
The "x + 1" is in parentheses so that the number x + 1 is appended to the string instead of x and 1 being appended separately.
|
|
|
|
|
Hi thanks for replying, I did not realize that Microsft Word auto-correct changed the var keywords to vary. I was able to get the code to work with your help.
modified 19-Jan-14 12:23pm.
|
|
|
|
|
Your code was not working because of the [] in declaration of your variable
stringArray
Try this one out
var stringArray = new Array(3);
for(x=0; x<stringArray.length-1; x ++)
{
stringArray[x]= "string" + (x+1);
}
If you add "string" +x+1 the output will be
string11
string21
string31
I'm sure that's not what you want.
|
|
|
|
|
Good Day All
it has been a long day , i hope you had a good one. I am a bit tired, i need some help in the following
I have two pages.On Page 1 there is an onready even and there is a check that i do ,The Check is for a Query string , i am checking the querystring has value like this , if it has a value then redirect to Page2 and Pass the parameter.
function getParameterByName(name) {
var match = RegExp('[?&]' + name + '=([^&]*)').exec(window.location.search);
return match && decodeURIComponent(match[1].replace(/\+/g, ' '));
}
$(document).ready(function ()
{
var message = getParameterByName('cuid');
if (message != null)
{
window.location = "Page2.html?cuid=A1E428F5-6D6B-4A40-854B-3B0E01BBA790";
}
});
Now on Page2 i check if there is Query string "cuid" and i check if its not null as i did below
$(document).ready(function ()
{
var message = getParameterByName('cuid');
alert(message);
if (message == null) {
window.location = "Page1.html";
}
});
if its null i redirect to Page1, now my problem here is that i can see it redirect to Page2 , but immediately it gets redirected to Page1 , the Querystring is null even if i have supplied it.
Please Help
Thanks
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa[at]dotnetfunda.com
http://www.Dotnetfunda.com
|
|
|
|
|
So, getParameterByName is not working then?
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
can we convert krutidev to unicode in javascript?
|
|
|
|
|
I apologize if as a non-programmer this is inappropriate since this site is "For those who code". Could someone step through the process of implementing the coding example at http://www.codeproject.com/Articles/599413/AplusLittleplusHTML5-3aplusUsingplusJSONplusandplu (A Little HTML5: Using JSON and File API to View Starred Google Reader Posts). I am trying to convert my Google reader starred Json file to bookmarks or html. I tried a Python script (http://www.howtogeek.com/162106/how-to-export-your-starred-items-from-google-reader) but results were flawed. The code mentioned here looks promising. So the questions are copy and paste into what files - and how, where should these files be, what about file names, what to do to start the code - run it in browser? and how, making sure code knows where to find html, css, javascript, json input and what about output - location, name, viewed in browser? etc. Thank you.
Brian F
|
|
|
|
|
I would suggest you post your question at the end of the article and ask the author for help. The actual code looks like it belongs in a web page so it should be part of your web site.
Veni, vidi, abiit domum
|
|
|
|
|
Thank You for your reply. Since as you say this code is meant for a web site, I will not be pursuing this matter any further. Creating a web site is beyond my abilities or interest and adapting it to work locally is also beyond me
|
|
|
|
|
The moment you step up to a device with a screen and method of input you are a computer programmer
|
|
|
|
|
I have a fairly complex (in my eyes) script that loads a JSON data file, and then creates a series of canvas elements (using kinetic.js) to layer these images into a div.
The div background is black, and the images are comprised of a single "background" jpg image, and about 20 png images that are laid on top of the background image.
Sometimes one or more of the following things happen:
0) The background image doesn't get rendered, but the png images do.
1) The background image is displayed on top of the png images (thus blocking them from view because it's a jpg image)
2) Some of the png images don't get rendered.
If I refresh the page after it's display the first time (with F5), it fixes it (sometimes it takes a couple of refreshes to fix it).
I will be able to provide a download link later today if you want to look at the code. Generally, though, I'm looking for ideas regarding things to check/do.
---------------------------------
EDIT: I think I've solved the issue by using the jquery Deferred function.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
modified 27-Dec-13 6:07am.
|
|
|
|