- 724 Posts
- 3 Reply Likes
Posted 4 years ago
- 724 Posts
- 3 Reply Likes
- 724 Posts
- 3 Reply Likes
Suggest me better, thank u
Petra V., Champion
- 7794 Posts
- 1391 Reply Likes
- make either one mandatory (let user decide which one), so you can contact him directly
- make none mandatory; if user doesn't supply data he will not be contacted
- additionally: supply an overview page with complaints and status, so every user can see in the app what the status of each complaint is, OR
after receiving a complaint, display a randomly generated Complaint ID (not the autoincrement PK, of course), with which the user can check the Complaint status in the app (since he doesn't now the ID of other Complaints, he will not have access to them). You can keep his Complaint ID's in localStorage for future reference, but these data won't be available in other devices, unless you create a sync mechanism.
- 724 Posts
- 3 Reply Likes
-As far as I understand, I should make another column in Complaint table e.g. COMPLAINNO , Is it possible to have two auto_increment fields in same table? one is Pk (1,2,3,4......n) and second COMPLAINNO (COMPNO001, COMPNO002, COMPNO002.....COMPNO00n)?
-After Successfully submit the form, user can see another page or dialog box with caption "Your Complain Has been booked, and your complain no. is COMNO0089, Please check the status here. and whenever user will click on here link, he can find another page with small form have two fields (Please enter Complain no. and email/phone), and when he will submit the small form, he can fetch the details from database e.g. solved or unsolved.Am i going right?
Petra V., Champion
- 7794 Posts
- 1391 Reply Likes
Is it possible to have two auto_increment fields in same table?Yes. But for this randomly generated ComplaintNO you don't want an auto_increment, because users could then guess the complaint numbers of others.
(In fact, you could use this randomly Complaint number as primary key instead of the auto-increment field, as long as you make sure it's unique)
Am i going right?Why so complicated? Would you like to use functionality like that if you were the user?
If I were the person filing complaints, I would expect an overview with my complaints and their statuses (and I should be able to access that overview anytime, not just from a 'here' link in that one-time message..
Or at least a small form page where I can enter the complaint number and see its status. Why should I enter email/phone just to see the status of my complaint?
Anyway: what were the community's requirements regarding feedback to the user who filed a complaint?
- 724 Posts
- 3 Reply Likes
-It should be a different form for users they can see statuses anytime. And just by enter a randomly created COMPLAINTNO. I got it , Thank you PETRA sooooo much. Petra as Jesse said, I should not ask help to you? You feel irritated or bad?
The community is totally depended on me, they just said ask for user's complaint, and they will sortout problems and update their databases.
Petra Once again THANK YOU SO MUCH, i can't forget your favors on me.
You know You are teaching me here, IT .
"You are my Inspirational person now in the world."
- 724 Posts
- 3 Reply Likes
left(uuid(), 8)
and it's returned
326f8afe
So it's correct to create random data?
- 724 Posts
- 3 Reply Likes
<script>
function myFunction() {
var x = document.getElementById("demo")
x.innerHTML = Math.floor((Math.random() * 1000000) + 1);
}
</script>
If I am using this function, so it will be unique numbers b/w 1 and 1000000?
Evertime when I will call it?
- 724 Posts
- 3 Reply Likes
That all the numbers it's showing all are different or not
Petra V., Champion
- 7794 Posts
- 1391 Reply Likes
But....you must make sure that the number you get is unique (not yet in database). That would require an additional ajax call to check if the number is already taken, OR a mechanism to make sure it is unique (for instance by concatenating a timestamp - or at least a microtime - to the number).
- 724 Posts
- 3 Reply Likes
- 724 Posts
- 3 Reply Likes
Petra V., Champion
- 7794 Posts
- 1391 Reply Likes
You want to do 7,8,9 before doing the client/server communication?
And where is your backend development?
- 724 Posts
- 3 Reply Likes
Petra V., Champion
- 7794 Posts
- 1391 Reply Likes
(If I were the IT boss of that community, I would make sure that
- the backend is hosted where I can manage it
- the sources of the application are in my possession
- generally: I want to be independent of the supplier and thus reduce risks)
- 724 Posts
- 3 Reply Likes
- 724 Posts
- 3 Reply Likes
- 724 Posts
- 3 Reply Likes
I have few questions/problems:
1. How I can validate my 'Email/Mobile' filed with correct phone NUmber or email is same field?
2. I have three buttons in my 'Post Complain' Page, and thrice are behaving like submit buttons, Whenever I am clicking 'Capture Photo' or 'Choose from Gallery' Buttons, both they are behaving like 'Submit' Buttons, they are working properly, but they are validating fields, and when I am coming back from both buttons after choose/capture picture, the all fields are going blank.
Can u find out the problems?
Petra V., Champion
- 7794 Posts
- 1391 Reply Likes
If it's a valid mail address, treat it as email, otherwise issue an error message.
2. They should not behave as submit buttons. But since I can't see your code, I have no idea what you are doing wrong this time.
- 724 Posts
- 3 Reply Likes
<button onclick="capturePhoto();">Capture Photo</button> <br>
<img style="display:none;width:60px;height:60px;" id="smallImage" src="" /><br>
<button onclick="getPhoto(pictureSource.PHOTOLIBRARY);">From Photo Library</button><br>
<img style="display:none;width:60px;height:60px;" id="smallImage" src="" />
<input type="submit" value="Submit" class="button button-pill button-action button-large">
Java Script:
<script type="text/javascript" charset="utf-8">
var pictureSource; // picture source
var destinationType; // sets the format of returned value
// Wait for Cordova to connect with the device
//
document.addEventListener("deviceready",onDeviceReady,false);
// Cordova is ready to be used!
//
function onDeviceReady() {
pictureSource=navigator.camera.PictureSourceType;
destinationType=navigator.camera.DestinationType;
}
// Called when a photo is successfully retrieved
//
function onPhotoDataSuccess(imageData) {
// Uncomment to view the base64 encoded image data
// console.log(imageData);
// Get image handle
//
var smallImage = document.getElementById('smallImage');
// Unhide image elements
//
smallImage.style.display = 'block';
// Show the captured photo
// The inline CSS rules are used to resize the image
//
smallImage.src = "data:image/jpeg;base64," + imageData;
}
// Called when a photo is successfully retrieved
//
function onPhotoURISuccess(imageURI) {
// Uncomment to view the image file URI
// console.log(imageURI);
// Get image handle
//
var largeImage = document.getElementById('largeImage');
// Unhide image elements
//
largeImage.style.display = 'block';
// Show the captured photo
// The inline CSS rules are used to resize the image
//
largeImage.src = imageURI;
}
// A button will call this function
//
function capturePhoto() {
// Take picture using device camera and retrieve image as base64-encoded string
navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 50,
destinationType: destinationType.DATA_URL });
}
// A button will call this function
//
function capturePhotoEdit() {
// Take picture using device camera, allow edit, and retrieve image as base64-encoded string
navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 20, allowEdit: true,
destinationType: destinationType.DATA_URL });
}
// A button will call this function
//
function getPhoto(source) {
// Retrieve image file location from specified source
navigator.camera.getPicture(onPhotoURISuccess, onFail, { quality: 50,
destinationType: destinationType.FILE_URI,
sourceType: source });
}
// Called if something bad happens.
//
function onFail(message) {
alert('Failed because: ' + message);
}
Petra V., Champion
- 7794 Posts
- 1391 Reply Likes
In fact, there is no form element, so the first thing to do is use a Validator or Lint to validate your html code.
- 724 Posts
- 3 Reply Likes
<form name="myForm" action="#" onsubmit="return validateForm()" method="post">
<input type="text" name="personname" placeholder="Name" required class="text"><span class="error">*</span><br><br>
<input type="text" name="emailphn" placeholder="Email/Mobile" required class="text"><span class="error">*</span><br><br>
<textarea cols=30 rows=5 placeholder="Enter Complain's Address" name="locationtxt" width=100% style="background:#12192C; width:80%; border-radius:0 6px 6px 0; border:none; outline:none; color:#999; font-family: 'Source Sans Pro', sans-serif"></textarea>
<textarea cols=30 rows=5 placeholder="If other, please specify!" name="otherdescription" class="textarea"></textarea>
<br>
<button onclick="capturePhoto();">Capture Photo</button> <br>
<img style="display:none;width:60px;height:60px;" id="smallImage" src="" /><br>
<button onclick="getPhoto(pictureSource.PHOTOLIBRARY);">From Photo Library</button><br>
<img style="display:none;width:60px;height:60px;" id="smallImage" src="" />
<input type="submit" value="Submit" class="button button-pill button-action button-large">
</p></form>
Java Script for Validation
<script type="text/javascript">
function validateForm()
{
var x=document.forms["myForm"]["personname"].value;
if (x==null || x=="")
{
alert("Name must be filled out");
return false;
}
var y=document.forms["myForm"]["emailphn"].value;
if (y==null || y=="") {
alert("Email/Phone must be filled out");
return false;
}
}
</script>
Petra V., Champion
- 7794 Posts
- 1391 Reply Likes
Add a
type attribute with value "button" to the button elements. Otherwise, the default type value would be 'submit'.
Official documentation:
https://www.w3.org/TR/2011/WD-html5-2...
- 724 Posts
- 3 Reply Likes
type="button"Its also not doing empty fields. Thank You Petra, Like always You are here with me, havn't words to pay yout thanks:)- 724 Posts
- 3 Reply Likes
with lots of trials I made validation for 'Email or Mobile Number field' and It's now working fine, have a look:
var email = document.getElementById('emailphn');
var mailFormat = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})|([7-9]{1}[0-9]{9})+$/;
if (email.value == "") {
alert( " Please enter your Email or Phone Number ");
}
else if (!mailFormat.test(email.value)) {
alert( " Email Address / Phone number is not valid, Please provide a valid Email or phone number ");
return false;
}
have a form look now, i made it beautiful :D.
but i have a little problem now:
When I am capturing picture, its showing in image block, and when I am uploading the image it's also showing in the image block, Can't I do like this: that whenever i capture image it show only captured image, ? and when i upload image it how only uploaded picture in the image block? and vice versa?
I mean only one image can hold in the image block which is used after.
It's a snap shot below i am facing problem

- 724 Posts
- 3 Reply Likes
Petra V., Champion
- 7794 Posts
- 1391 Reply Likes
Then only show one image, not both. Clear the image area first, before adding a new one.
- 724 Posts
- 3 Reply Likes
see java script:
<script type="text/javascript" charset="utf-8">
var pictureSource; // picture source
var destinationType; // sets the format of returned value
// Wait for Cordova to connect with the device
//
document.addEventListener("deviceready",onDeviceReady,false);
// Cordova is ready to be used!
//
function onDeviceReady() {
pictureSource=navigator.camera.PictureSourceType;
destinationType=navigator.camera.DestinationType;
}
// Called when a photo is successfully retrieved
//
function onPhotoDataSuccess(imageData) {
// Uncomment to view the base64 encoded image data
// console.log(imageData);
// Get image handle
//
var smallImage = document.getElementById('smallImage');
// Unhide image elements
//
smallImage.style.display = 'block';
// Show the captured photo
// The inline CSS rules are used to resize the image
//
smallImage.src = "data:image/jpeg;base64," + imageData;
}
// Called when a photo is successfully retrieved
//
function onPhotoURISuccess(imageURI) {
// Uncomment to view the image file URI
console.log(imageURI);
// Get image handle
//
var largeImage = document.getElementById('largeImage');
// Unhide image elements
//
largeImage.style.display = 'block';
// Show the captured photo
// The inline CSS rules are used to resize the image
//
largeImage.src = imageURI;
}
// A button will call this function
//
function capturePhoto() {
// Take picture using device camera and retrieve image as base64-encoded string
navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 50,
destinationType: destinationType.DATA_URL });
}
// A button will call this function
//
function capturePhotoEdit() {
// Take picture using device camera, allow edit, and retrieve image as base64-encoded string
navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 20, allowEdit: true,
destinationType: destinationType.DATA_URL });
}
// A button will call this function
//
function getPhoto(source) {
// Retrieve image file location from specified source
navigator.camera.getPicture(onPhotoURISuccess, onFail, { quality: 50,
destinationType: destinationType.FILE_URI,
sourceType: source });
}
// Called if something bad happens.
//
function onFail(message) {
alert('Failed because: ' + message);
}
</script>
HTML
<table border=0 width=100%><tr><td><button type="button" onclick="capturePhoto();" class="btn"><img src="images/placeholder.png" width="30" height="25" align="center">Take Photo</button> </td><td>
<button type="button" onclick="getPhoto(pictureSource.PHOTOLIBRARY);" class="btn">+Upload Image</button>
</td></tr></table>
<br>
<img style="display:none;width:120px;height:120px;" id="smallImage" src="" />
<img style="display:none;width:120px;height:120px;" id="largeImage" src="" />
<input type="submit" value="Submit" class="button button-pill button-action button-large">
Petra V., Champion
- 7794 Posts
- 1391 Reply Likes
- 724 Posts
- 3 Reply Likes
and which value should i use?
Both are showing images in image area, but I want in same image area i cud use img src, of getphoto if a user files take photo option , and it will be change in img src of getPhoto(source), if a user upload the pic.
Petra V., Champion
- 7794 Posts
- 1391 Reply Likes
- 724 Posts
- 3 Reply Likes
2.I kept the value of DestinationType.FILE_URI because i read the following statement regarding DestinationType.
Ok may be because we are not using File Uri we r using base64 images, i m changing it. thank you
- 724 Posts
- 3 Reply Likes
You just give me this answer please, i am going too much confused:
destinationType's value will be same for both functions? e.g. capturePhoto() & getPhoto(source) ?
Petra V., Champion
- 7794 Posts
- 1391 Reply Likes
However, YOU must decide whether you want base64 or not. That's an application decision. Both are valid choices.
- 724 Posts
- 3 Reply Likes
I was asking because u said, read docs carefully, and whenever I read about capture photo and getphoto, everywhere they used FILE_URI for get photo from Library, When u said , i changed the value of FILE_URI to DATA_URL, It's giving option to select a photo from Library but not showing thumbnail, Look:
and when I am using FILE_URI, it's showing thumnail in Image area: Please tell me what I do?
- 724 Posts
- 3 Reply Likes
thanks in advance:
<script type="text/javascript" charset="utf-8">
var pictureSource; // picture source
var destinationType; // sets the format of returned value
// Wait for Cordova to connect with the device
//
document.addEventListener("deviceready",onDeviceReady,false);
// Cordova is ready to be used!
//
function onDeviceReady() {
pictureSource=navigator.camera.PictureSourceType;
destinationType=navigator.camera.DestinationType;
}
// Called when a photo is successfully retrieved
//
function onPhotoDataSuccess(imageData) {
// Uncomment to view the base64 encoded image data
// console.log(imageData);
// Get image handle
//
var smallImage = document.getElementById('smallImage');
// Unhide image elements
//
smallImage.style.display = 'block';
// Show the captured photo
// The inline CSS rules are used to resize the image
//
smallImage.src = "data:image/jpeg;base64," + imageData;
}
// Called when a photo is successfully retrieved
//
function onPhotoURISuccess(imageData) {
// Uncomment to view the image file URI
// console.log(imageURI);
// Get image handle
//
var smallImage = document.getElementById('smallImage');
// Unhide image elements
//
smallImage.style.display = 'block';
// Show the captured photo
// The inline CSS rules are used to resize the image
//
smallImage.src = "data:image/jpeg;base64," + imageData;
}
// A button will call this function
//
function capturePhoto() {
// Take picture using device camera and retrieve image as base64-encoded string
navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 50,
destinationType: destinationType.DATA_URL });
}
// A button will call this function
//
function capturePhotoEdit() {
// Take picture using device camera, allow edit, and retrieve image as base64-encoded string
navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 20, allowEdit: true,
destinationType: destinationType.DATA_URL });
}
// A button will call this function
//
function getPhoto(source) {
// Retrieve image file location from specified source
navigator.camera.getPicture(onPhotoURISuccess, onFail, { quality: 50,
destinationType: destinationType.DATA_URL,
sourceType: source });
}
// Called if something bad happens.
//
function onFail(message) {
alert('Failed because: ' + message);
}
</script>
Petra V., Champion
- 7794 Posts
- 1391 Reply Likes
Above, I spelled out for you what the value of attribute 'destinationType' should be:
The value should be Camera.DestinationType.DATA_URL
And yet, you still have
destinationType: destinationType.DATA_URL,
==============
I was asking because u said, read docs carefully, and whenever I read about capture photo and getphoto, everywhere they used FILE_URI for get photo from Library, When u said , i changed the value of FILE_URI to DATA_URLI did not tell you to use DAT_URL instead of FILE_URI (and in fact NATIVE_URI would be even better than FILE_URI)! I just gave you an example of the proper classes to use when specifying the destinationType.
I also said (6 days ago) that you need to decide which of both you want to use:
- file format
- base64 format
That decision will determine the field type of image in your database and the way you want to retrieve the image in the backend (in other words: how do you want to display the image to the community's responsible person?).
Apart from that, you have still more decisions to make, which I already pointed out a week ago:
- have you decided what you want your app to do if it goes offline?
- have you decided what you want your app to do if no such services are available?
- do you meanwhile have an app id, as approved by the community?
- 724 Posts
- 3 Reply Likes
1.The second things, can we store both images in base64 encoding, as I did above?
If not then capturephoto() with DATA_URL and getphoto() with NATIVE_URI, right?
Petra all decisions are up to you, you just tell me do this, and I will.
-Obviously they want to see picture in DATA_URL not only File url.
Some more Decisions
-If a user file a complaint without having internet connection, and will try to submit offline, a dialog box will apear with message: "Check you Internet Connection"
-a dialog box with service is not available at your device/
-I created an app ID, by google?
Petra V., Champion
- 7794 Posts
- 1391 Reply Likes
Petra all decisions are up to you, you just tell me do this, and I will.Oh no! Certainly not! That would spoil all the fun.
It is you who makes the decisions, and I who will tell you that your decisions are wrong. That's how we are playing this project.
- 724 Posts
- 3 Reply Likes
May be you are tired or irretated from me now.
-It was you hu suggest me to use static map image,
-it was you hu want to store base64 encoding images.
and blah blah blah,
I am not saying that everything you decide for my app, but truth is that the app which is now stand, only by u, by your guidance i could do this.
You are experienced ITian.
I am just asking for better for me.
Promise I will not appear here again once my app got completely build.
Thanks for your favors.
Petra V., Champion
- 7794 Posts
- 1391 Reply Likes
Petra what happened to you since yesterday?Nothing. My above remark was supposed to be half-way funny.
(But bots aren't good at humor)
- 724 Posts
- 3 Reply Likes
-I can guess, that you are near about 45-50 years old man.
isn't?
Petra V., Champion
- 7794 Posts
- 1391 Reply Likes
- 724 Posts
- 3 Reply Likes
- 724 Posts
- 3 Reply Likes
See dashboard now:
before i go ahead, I want you check my enable/disable coding, it's working fine, though.
function EnableDisableTextBox(mycheck) {
var locationtxt = document.getElementById("locationtxt");
locationtxt.disabled = mycheck.checked ? true : false;
locationtxt.style.background = "#DDD";
if (!locationtxt.disabled) {
locationtxt.focus();
locationtxt.style.background = "#12192C";
}
}
function EnableDisableTextarea(othercheck) {
var otherdescription = document.getElementById("otherdescription");
otherdescription.disabled = othercheck.checked ? false : true;
student.disabled = othercheck.checked ? true : false;
otherdescription.style.background = "#DDD";
if (!otherdescription.disabled) {
otherdescription.focus();
otherdescription.style.background = "#12192C";
}
else
{
student.focus();
}
}
</script>
-if a user will fill the Location text in text field, He can'r choose current location, and when he will try to choose current location, the LOCATION TEXT field will disable.
-if a user will choose complaint type from pick list, the other description field will be disable, and when He will click on other, the pick list will be deactivate.
Is it correct?
I also created a small form for check complaint status.
with Validation of complaint type number.

Petra V., Champion
- 7794 Posts
- 1391 Reply Likes
What do you have such variable for?
- 724 Posts
- 3 Reply Likes
<select name=student id=student>
<option value="">-Complain Regarding to:-</option>
</select>Petra V., Champion
- 7794 Posts
- 1391 Reply Likes
Anyway, that variable 'student' in the script is still undefined, because you don't have it set to the form element object.
- 724 Posts
- 3 Reply Likes
<script>
$(document).ready(function() {
//////////////////////
$.getJSON("compltype-data.php", function(return_data){
$.each(return_data.data, function(key,value){
$("#student").append("<option value=" + value.compltypeid +">"+value.description+"</option>");
});
});
//////////////////////
////////////
$('#student').change(function(){
//var st=$('#student option:selected').text();
var st=$('#student').val();
alert(st);
});
/////////////////////
});
</script>
compltype-data.php
<?Php
require "config.php"; // Database Connection
$sql="select compltypeid, description from compltype where active='y' order by description asc ";
$row=$dbo->prepare($sql);
$row->execute();
$result=$row->fetchAll(PDO::FETCH_ASSOC);
echo json_encode(array('data'=>$result));
?>
-Yes you are right I should use meaningful variable names.
Related Categories
-
PhoneGap Build
- 15111 Conversations
- 275 Followers
-
Plugins
- 1283 Conversations
- 38 Followers


