Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
in the updates.. with my code above, it is working if i only choose 1 row but when i have chosen more than 1 row, the value in the last row that i inserted is the only value that mysql is using to updates all rows. 2 yes it is intended. i need it for my updates, 3rd sorry, but i am using CSS though i will clean my code after i finish my program, im just stack here
This is my parent window HTML code
JAVASCRIPT
function MM_openBrWindow(theURL,winName,features) { //v2.0
var chkValue = "";
var counter = "";
for (var i=0; i < document.myForm.chkbox.length; i++)
{
if (document.myForm.chkbox[i].checked)
{
chkValue = chkValue + document.myForm.chkbox[i].value + " ";
}
counter ++;
}
var queryString = "&chkValue=" + chkValue;
// location = "featuredaction.php" + queryString
//var queryString = "id=" + id;
var theURL = theURL + queryString;
//var tbreceiptno= document.getElementById('checkbox').value;
window.open(theURL,winName,features);
}
I think i will fgure it out my own thanks everyone..
You have fault in your second line $chkValueArr=explode(" ", $chkValue);. You dont have to explode it. You already got an Array of checkbox value when you wrote $chkValue=$_GET['chkValue']; Assuming your HTML form is something like:
<input type="checkbox" name="chkValue[]" value="val 1">
<input type="checkbox" name="chkValue[]" value="val 2">
<input type="checkbox" name="chkValue[]" value="val 3">
You can loop over all checkbox values by:
foreach($chkValue as $chk)
{
echo $chk;
}
This will print val 1, val 3 if you selected those checkboxes in your form.
You can check the array by writing print_r($chkValue)
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
How to Add One Value to the "0001". When I am adding one value to this number the result shows only 2.How can i get 0002?
I am using this code:
var pcode = $('#productcode').val(); // Now the pcode value is 0001
var num= parseInt(pcode) + 1;
But the result shows only 2
Just call this function after adding..
function z4(n) {
var sign = +n < 0;
n = ''+n;
while(n.length<4) n = '0' + n;
return (sign ? '-' : '' ) + n;
}
z4(2); // 0002
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
So, let's say I want to have a piece of text on my website, that changes color every second. I do know how to use JS to change the color of the text, but not how to continue to auto-change it based on certain parameters. For example, cycling through thousands of colors, not just one or two.
ok here is a simple way to blink text with colors
Js :
// List of colors
var spectrum = ['#f00', '#f66', '#969', '#00F', '#0FB53F'];
var cycle = spectrum.length-1;
// Cycle speed
var speed = 300;
var i = 0;
window.setInterval(function(){
document.getElementById('index').style.color = spectrum[i];
if (i < cycle) i++;
else i = 0;
}, speed);
HTML
<p id="index">Flashing text</p>
Demo
You can simple use html inside PHP:
echo "<font color='red'>Hello World</font>";
for a loop you can simple create an array with all the html collors:
$colors=array();
$colors[1]="red";
$colors[2]="blue";
// soo on....
foreach($colors as $color){
echo "<font color='$color'>Hello World</font>";
}
setInterval is what you want.
Fiddle
http://www.w3schools.com/jsref/met_win_setinterval.asp
var myColours = [...];
var index = 0;
var myElement = /*get your element*/
setInterval(function() {
/* Set your element. Are you using Javascript to get your element? */
myElement.style.color = myColours[index];
/* Are you using jQuery? */
myElement.css('color', myColours[index]);
index++;
if(index > myColours.length - 1){
index = 0;
}
}, 1000);
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
i'm trying to follow this tutorial guide on this website http://homepage.ntlworld.com/kayseycarvey/jss3p11.html?
However, i met some difficultly when doing so.
Even though i did the exact same thing. Please guide me if you know so.
Here are what i did:
<html>
<script>
function GetSelectedItem() {
chosen = ""
len = document.f1.r1.length
for (i = 0; i <len; i++) {
if (document.f1.r1[i].checked) {
chosen = document.f1.r1[i].value
}
}
if (chosen == "") {
alert("No Location Chosen")
}
else {
alert(chosen)
}
}
</script>
<body>
<form name="f1">
<Input type = radio Name = r1 Value = "NE">North East
<Input type = radio Name = r1 Value = "NW">North West
<Input type = radio Name = r1 Value = "SE">South East
<Input type = radio Name = r1 Value = "SW">South West
<Input type = radio Name = r1 Value = "midlands">Midlands
</form>
</body></script>
</html>
On a side note, do i have to do anything to the form in order to trigger the function GetSelectedItem ?
Thanks in advance !
add GetSelectedItem ()function on onchange event of your radio button
<input type="radio" onclick="GetSelectedItem()" value="NE" name="r1">
Add onsubmit="javascript:GetSelectedItem();" to your form tag.
window.addEventListener('load', function () {
for (var i = 0; i < document.f1.r1.length; i++) {
document.f1.r1[i].addEventListener("click", GetSelectedItem);
}
}, false);
function GetSelectedItem() {
alert(this.value);
}
http://jsfiddle.net/udSbL/2/
try this
<input type="radio" onclick="autosubmit(this.value)" value="NE" name="r1">
<script type="text/javascript">
function autosubmit(value) {
window.location='update.php?radiovalue='+value;
}
</script>
update.php
$rbtn=$_GET['radiovalue'];
//here your update query
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I'm trying to make an auto complete forum (like the tags below) that works in lime-survey. I'm new to this so please explain everything like i'm 5 :)
My goals are:
auto complete to work
work with lime-survey
have an excel file or maybe a database using PHP/MySQL that anyone can manage by editing. It would only be ONE row. Please point me how to do this. I use a mac :)
Here is the code:
<!DOCTYPE HTML>
<html>
<body>
<div >
<input type="text" id="raw_input" width="100" height="30" name="box" onkeyup=show(this)>
</div>
<div id="drop_down" style="display:none">
<SELECT id=box size=3 name="box" onclick=show(this)></SELECT>
</div>
<script>
function drop_the_box() {
document.getElementById("drop_down").style.display = "none";
document.getElementById('box').length = 0;
if (!randomcharactersblablabla).test(document.getElementById("raw_input").value){
document.getElementById("drop_down").style.display="block";
var database = new Array("object_1","item_1","object_2","item_2");
var string = document.getElementById("raw_input").value;
for (var s = 0; s < database.length; s+= 1 ) {
var t += 1
if (database[s].indexOf(string) != 0) {
addItem(string[s],database[s]);
scan(streetArray[s],streetArray[s]);
}
}
}
}
function scan(x,y) {
var ghost_tag = document.createElement("ghost");
document.getElementById("box").options.add(ghost_tag);
ghost_tag.text = x;
ghost_tag.value = y;
}
function show(visable) {
document.getElementById("dropdown").value = visable.value;
}
</script>
</body>
</html>
Keep you data in mysql database. Create php file which will handle queries. Use jquery.ajax() to send queries and retrieve responses from php file.
Use this example
jQuery file
$('#search').change(function(){
var name = $('#search').val();
$.ajax({
type: 'POST',
url: 'request.php',
data: 'some data(may be variable)',
success: function(response){
$('#searach').val(response);
}
});
})
php file
if(isset($_POST['some_data'])){
$query = 'SELECT your_table_field FROM your_table WHERE your_table_field LIKE %$_POST['some_data']% LIMIT 1';
$result = mysql_query($query);
$myrow = mysql_fetch_array($result);
echo $myrow[0];
}
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I need the first two letter of the first name and the last name which will type in text box like Salman Shaikh so it will cm some where in my page as SASH i need this.
Here is live example with jQuery.
http://jsfiddle.net/rPTrK/
I'll paste the code in here also -
jQuery(document).ready(function() {
jQuery("#submit").click(function() {
var firstName = $("#name").val().substr(0, 2);
var surname = $("#surname").val().substr(0, 2);
$("body").append(firstName+surname);
});
});
In case you don't know - jQuery is JS library. You can get it here . Download the latest jquery release and insert it in your html/php file between the tags, just like you normally insert js scripts.
Attention: You must insert my created code only after you have inserted the jQuery library, otherwise it won't work.
EDIT: Updated to your suggested version -
http://jsfiddle.net/pg8La/
Code -
jQuery(document).ready(function() {
jQuery("#form1").change(function() {
var firstName = $("#name").val().substr(0, 2);
var surname = $("#surname").val().substr(0, 2);
if(firstName != "" && surname != "") {
$("body").append(firstName+surname);
}
});
});
EDIT 2: Final example per your request -
http://jsfiddle.net/K52fR/
And code here -
HTML
<form id="form1">
<input type="text" name="name" id="name" placeholder="name" />
<br />
<input type="text" name="surname" id="surname" placeholder="surname" />
<br />
<h2 id="text">WSCPP<span id="nameSurname"></span><span id="time"></span><span id="randomNr"></span></h2>
</form>
jQuery/JS -
jQuery(document).ready(function() {
jQuery("#form1").change(function() {
var firstName = $("#name").val().substr(0, 2);
var surname = $("#surname").val().substr(0, 2);
if(firstName != "" && surname != "") {
$("#nameSurname").text(firstName+surname);
}
});
var currentTime = new Date();
var month = currentTime.getMonth() + 1;
var day = currentTime.getDate(); var year = currentTime.getFullYear();
$("#time").text(day + "" + month + "" +year);
$("#randomNr").text(Math.floor(Math.random()*90000+9999));
});
I assume that you are POST-ing the data to some page which is why you have a tag php
in your question.
$firstname = substr($_POST['firstname'],2);
$lastname = substr($_POST['lastname'],2);
Check following for program
http://jsfiddle.net/YNV87/
How about this:
$_REQUEST['firstname'] = 'Salman ';
$_REQUEST['lastname'] = 'Shaikh';
$firstname = strtoupper(substr($_GET['firstname'], 0, 2));
$lastname = strtoupper(substr($_GET['lastname'], 0, 2));
echo $firstname.$lastname;
Explode the string to an array.
$name_array=explode(' ',$name);
$first=substr(trim($name_array[0]),0,2);
$last=substr(trim($name_array[1]),0,2);