The problem must be your PHP codes. Check your PHP codes or post here.
) no, was not in php. Your code gave some help..instead of making new div element i simply needed to make new input element and append it on div) so thanks) solved)
The problem must be your PHP codes. Check your PHP codes or post here.
) no, was not in php. Your code gave some help..instead of making new div element i simply needed to make new input element and append it on div) so thanks) solved)
No. Most said correct. Database is in the server. Javascript works on client's machine. The only way is to have some script running on server (like php) that would retrieve data from database and pass it to javascript.
1. make sure your variables contain quotes from both sides..for example $razonsocial="somevalue".
2. try writing like this..for example
"where razonsocial=".$razonsocial;
and if those two steps don't work, simply replace this code
mysql_query($query);
with this one
$result=mysql_query($query);
if(!$result){die("Error: ".mysql_error());}
to see what error you have
addPhoto.innerHTML = addPhoto.innerHTML +"<br/><input type='file' name='flImg'+ i>";
You need to insert the quote here
<input type='file' name='flImg'" + i + "'>"
This one may help you.function AddMore() { var i = document.frmExhbt.addN.value; var ele = document.getElementById('addPhoto'); i=parseInt(i); i++; document.frmExhbt.addN.value=i; var newFile = document.createElement('DIV'); newFile.innerHTML = '<input type="file" name="flImg' + i + '" />'; newFile.innerHTML += '<input type="text" name="txtTtl' + i + '" />'; ele.appendChild(newFile); }
Hope this help..!
Well your notification is correct. It should be written that way..but that did not change the working way for file element. Thx for help anyway:)
Hi) I needed to make it possible for the user to upload many files from many directories of his pc to server. Here is the html and js code
html
<div id="addPhoto" >
Path and Title of the Photo.
<br /><br />
<input type="file" name="flImg0" />
<input type="text" name="txtTtl0" />
<input type="hidden" name="addN" value="0" />
</div>
<input type="button" value="Add another" name="btnAdd" onclick="AddMore();"/>
js
function AddMore()
{
var i = document.frmExhbt.addN.value;
i=parseInt(i);
i++;
document.frmExhbt.addN.value=i;
addPhoto.innerHTML = addPhoto.innerHTML +"<br/><input type='file' name='flImg'+ i>";
addPhoto.innerHTML = addPhoto.innerHTML +" <input type='text' name='txtTtl'+ i>";
}
This works for making more text fields and fields for uploading files. BUT, but when i select first file to upload, and then the second..the first one seems to disappear. Although the same doesn't happen for textfields. Thanks for help.
hi kracko,
if you need to run code multiple times on the same page, then a function would probable be the best approach, you can just call the function when needed. If you need to run the code multiple times on different pages, then the require (or include) approach would serve you better.
Zagga
thanks! A lot!
If it is simpler (less code) then it is probably better. If you need to do the same thing multiple time using different parameters then a function would seem to be the way to go. Unless there is a lot of complex / extra code in the function to make sense of the input parameters and what you need to do with them (versus customized modules for each type of parm), then it won't have any performance impact.
thanks a lot) just one more question. If I need to do the same thing multiple times.. i can also require corresponding php file multiple times.. What do you think..are functions still a better way?
I cant decide if it is appropriate to use user defined functions for every single action in a page..or it somehow may slow the work? I can alternatively make different php files instead of functions,,and they will do the same thing depending on values of some variables, but i would like to do it the right way. Maybe making functions is better? how you think?
ok js file is correct. But html file should be like this
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript" src="numbers.js"></script>
</head>
<body>
<input type="text" id="value1" value="" />
<input type="text" id="value2" value="" />
<input type="submit" name="Submit" onclick="addNumbers()" />
<input type="text" id="answer" value="" />
</body>
</html>
I think the problem was in here
onclick="javascript:addNumbers()"/>
syntax error
<script type="text"/javascript" src="numbers.js"></script>
Should be
<script type="text/javascript" src="numbers.js"></script>
thank you guys. The path was really incorrect)
Hey ppl. I use apach and i've got a problem that i cant fix
when i write this code ..
<img
src="Z:/home/localhost/www/ImageGallery/Images/mmbg3xmx3g.gif"
width="100px" height="100px" name="imgPreview" />
no image is shown. Whats wrong? The image surely exists in the specified path.
And one more problem with this is that for some images the same code works.
thanks a lot. I guess header helped and don't have troubles with it yet:) But thank you all. It's a pleasure to ask something here:)
hey ppl. I have many submit buttons in a form. Each of them does its thing in different php pages. But when, for example, 'add' button goes to 'add.php' it does its work but stays there) how to redirect page back? thanks
without regex, the alternative is to list ALL the characters you don't want and use str_replace() to remove them - ex assuming you do not want any of the following:
# _ -then use:
$str=str_replace('#_-','',$str); echo $str;
but it is easier if you list only the ones that you DO want and use a regex to do the filtering.
tanks:)
all you need to do is use preg_replace() to remove the unwanted set of characters.
//your initial string $str = 'img*1L%^_ove>ly.jpg'; /* //this removes anything that is NOT //a,b,c,....z //A,B,C,...Z //0,1,2,...9 //In other words, it KEEPS only a-z, A-Z, and 0-9. //If you want other character(s), simply add //it(them) immediately after the "9" */ $str = preg_replace('#[^a-zA-Z0-9]#','',$str);
ok this would work but is there another way so that i wouldnt deal with regular expressions?
hey. I need to make file names be consisted of only numbers and letters. Like if there is an image named 'img*1L%^_ove>ly.jpg' it will become 'img1Lovely.jpg' . Only digits and letters (btw letters meaning even if not english letters). Thanks a lot. I went through php.net, failed finding sth like this. Maybe you profies know) or can advise me easy way to do it.
thanks Taywin..it finally worked. Can't believe that was the problem=\
aw well my code was very complicated..jst help me with this one i will figure out with mine
<input type="button" onclick="move()" value="go" />
<br />
<img src="btn16.gif" style=" position:absolute; height:100px; width:100px; top:20px" id="img" />
<script>
var k=0;
function move(){
var t=document.getElementById("img").style.top;
t=parseInt(t);
t+=15;
document.getElementById("img").style.top=t;
if(k<10){
k++;
setTimeout("move()",1);
}
}
</script>
aw well 'position:absolute' or relative was what i forgot to put. It now works in IE and Opera..but Firefox still stubborn=\
I want the picture to roll down on click not to just change it's place when clicked..that's why wrote with function=\
yeah and please if you figure it out correct it so that it works in firefox as well..cause i really have troubles with that browser=\
<input type="button" onclick="move()" value="go" />
<br />
<img src="btn16.gif" style="height:100px; width:100px; top:0px" id="img" />
<script>
var k=0;
function move(){
var t=document.getElementById("img").style.top;
t=parseInt(t);
t+=15;
document.getElementById("img").style.top=t;
if(k<10){
k++;
setTimeout("move()",1);
}
}
</script>
Hey. I didn't realy get what's your mistake..just corrected it my way and it works fine. Look..
<script>
function vowel(str){
var count = 0;
var myStr=new String(str);
myStr = myStr.toLowerCase();
for (i=0;i<myStr.length;i++){
if (myStr.charAt(i) == "a" || myStr.charAt(i) == "e" || myStr.charAt(i) == "i" || myStr.charAt(i) == "o" || myStr.charAt(i) == "u"){
count++;}
}
document.write("this string has " + count + " vowels in it! <br />");
}
vowel("hello");
</script>
Hey. I am new to webprogramming..so sorry if this question sounds stupid:D
I just wanted to make an animation but in firefox that animation just doesnt appear tho it works great in IE and opera. Do you have any idea what's wrong? I use the function setTimeout() and document.all[id].style...etc to take the value I need. No error but no animation as well=\