close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Perform function in php based on onChange javascript value passed before performing anything

Thread began 9/30/2020 11:34 am by lr_leal239405 | Last modified 10/01/2020 8:46 am by Ray Borduin | 29 views | 8 replies |

lr_leal239405

Perform function in php based on onChange javascript value passed before performing anything

I have a page (see link below) in which if you type something in the Part_no field, it performs JS function. The JS function does a search thru a db with PHP Mysql and if it finds matching value, it auto populates the other columns. That works fine. However, if it finds nothing, it still performs the function and populates with nothing. That is the flaw. I want it to Do NOTHING if it doesn't find a matching value. (still writing this question.. please hold)

function changeAllProdSelections(str) {
if (str == "") {
//document.getElementById("selections").innerHTML = "";
// location.reload();
return;
} else {
xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("selections").innerHTML = this.responseText;
}
};
xmlhttp.open("GET","changeAllProdSelections.php?q="+str,true);
xmlhttp.send();
}
}

Sign in to reply to this post

Ray BorduinWebAssist

if (this.readyState == 4 && this.status == 200) {

Should be:

if (this.readyState == 4 && this.status == 200 && this.responseText != "") {

Then it won't do anything if the response is blank.

Sign in to reply to this post
Did this help? Tips are appreciated...

lr_leal239405

I tried it and it still performs function. I've attached the files but also have FTP access above.

(If you can fix it for me or send answer with an open ticket (I think you'll fix it fast), then that's ok with me. Thank you)

Attached Files
changeAllProdSelections.php
jsscripts.php
quote_form_g_min_edit.php
Sign in to reply to this post

lr_leal239405

Hold on. Let me try something frst.

Sign in to reply to this post

lr_leal239405

ok. didn't work fo me. Let me know if you can just do it. Thank you.

Sign in to reply to this post

Ray BorduinWebAssist

Call me... I'll need more details on what exactly you want in the different scenarios.

Sign in to reply to this post
Did this help? Tips are appreciated...

lr_leal239405

I'll can try calling. But....here's an example part no. for it to auto populate: ST0005. I only care about the function named changeAllProdSelections(). If there's something already there, and you enter nothing, it leaves what was there. That's fine. If you input something that doesn't exist, make it do absolutely nothing (or just don't run that function) including not changing what was there. Just nothing.

Once I see that, I can probably fix the rest. Thanks.

Sign in to reply to this post

Ray BorduinWebAssist

I think if you add the code I suggested above and then update the changeAllProdSelections.php page and add this on line 10:

php:
<?php

if (!$WADAcac_prod_subcategory_leveltwo_NEW->TotalRows) die();
?>



That would probably do it.

Sign in to reply to this post
Did this help? Tips are appreciated...

lr_leal239405

Thanks. It put me in the right path even though the function still runs. So, now I have it so that the input fields just come back with all data when a part no. is not found. I think that's fine to show my boss for now.

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...