{"id":571,"date":"2019-09-13T23:37:04","date_gmt":"2019-09-13T23:37:04","guid":{"rendered":"https:\/\/delphijustin.biz\/?p=571"},"modified":"2019-09-14T17:48:41","modified_gmt":"2019-09-14T17:48:41","slug":"jsallelectronics-javascript-parts-ordering-script","status":"publish","type":"post","link":"https:\/\/delphijustin.biz\/jsallelectronics-javascript-parts-ordering-script\/","title":{"rendered":"jsAllElectronics &#8211; Javascript Parts Ordering Script"},"content":{"rendered":"\n<p>I wanted a solution for making my visitors easier for them to order parts to build my projects. This code comes from the &#8220;Order By Part#&#8221; Page. Heres an example of how to use it:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"html\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;script type=\"text\/javascript\" src=\"\/\/delphijustin.biz\/wp-content\/allelectronics.js\">&lt;\/script>&lt;!-- Load jsAllElectronics -->\n&lt;script type=\"text\/javascript\">\n\/* Here's how to call createAEForm\ncreateAEForm(parts_Array,buttonText)\nParameters:\nparts_Array Array of JSON objects containing parts Cat# and Qty\nbuttonnText Text inside of the button on the form.\n*\/\n\ncreateAEForm([{Cat:\"291-5.6K\",Qty:10},{Cat:\"293-10\",Qty:10}],\"Add Resistors to cart\");\/\/write form HTML to page\n&lt;\/script><\/pre>\n\n\n\n<p>Heres the source code of the utility:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"js\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/*\nParts ordering script off of all electronics. This utility is not from all electronics and doesn't checks if all parts are in stock. If a part \nis not in stock all except parts that were not in stock will be added\njsAllElectronics by Justin Roeder www.delphijustin.biz\n*\/\nfunction EnumParts(item,index){\nvar xitem=index+1;\ndocument.writeln('&lt;input type=\"hidden\" name=\"id['+xitem+']\" value=\"'+item.Cat+'\"\/>');\ndocument.writeln('&lt;input type=\"hidden\" name=\"qty['+xitem+']\" value=\"'+item.Qty+'\"\/>');\n}\nfunction createAEForm(parts,buttonText){\ndocument.writeln('&lt;form method=\"get\" action=\"https:\/\/www.allelectronics.com\/\">');\ndocument.writeln('&lt;input type=\"hidden\" name=\"type\" value=\"\" \/>');\ndocument.writeln('&lt;input type=\"hidden\" name=\"page\" value=\"item\" \/>');\ndocument.writeln('&lt;input type=\"hidden\" name=\"action\" value=\"cart\" \/>');\ndocument.writeln('&lt;input type=\"hidden\" name=\"id\" value=\"order_by_cat\" \/>');\ndocument.writeln('&lt;input type=\"hidden\" name=\"skip_redirect_suffix\" value=\"\" \/>');\nparts.forEach(EnumParts);\ndocument.writeln('&lt;input type=\"submit\" value=\"'+buttonText+'\">&lt;\/form>');\n}\n<\/pre>\n\n\n\n<h1>Real Example<\/h1>\n<script type=\"text\/javascript\" src=\"\/\/delphijustin.biz\/wp-content\/allelectronics.js\"><\/script><!-- Load jsAllElectronics -->\n<script type=\"text\/javascript\">\ncreateAEForm([{Cat:\"291-5.6K\",Qty:10},{Cat:\"293-10\",Qty:10}],\"Add Resistors to cart\");\/\/write form HTML to page\n<\/script>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I wanted a solution for making my visitors easier for them to order parts to build my projects. This code comes from the &#8220;Order By Part#&#8221; Page. Heres an example of how to use it: Heres the source code of the utility: Real Example<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"beyondwords_generate_audio":"","beyondwords_project_id":"","beyondwords_content_id":"","beyondwords_preview_token":"","beyondwords_player_style":"","beyondwords_language_id":"","beyondwords_title_voice_id":"","beyondwords_body_voice_id":"","beyondwords_summary_voice_id":"","beyondwords_error_message":"","beyondwords_disabled":"","beyondwords_delete_content":"","beyondwords_podcast_id":"","beyondwords_hash":"","publish_post_to_speechkit":"","speechkit_hash":"","speechkit_generate_audio":"","speechkit_project_id":"","speechkit_podcast_id":"","speechkit_error_message":"","speechkit_disabled":"","speechkit_access_key":"","speechkit_error":"","speechkit_info":"","speechkit_response":"","speechkit_retries":"","speechkit_status":"","speechkit_updated_at":"","_speechkit_link":"","_speechkit_text":""},"categories":[4],"tags":[20,23,22,21],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/delphijustin.biz\/wp-json\/wp\/v2\/posts\/571"}],"collection":[{"href":"https:\/\/delphijustin.biz\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/delphijustin.biz\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/delphijustin.biz\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/delphijustin.biz\/wp-json\/wp\/v2\/comments?post=571"}],"version-history":[{"count":5,"href":"https:\/\/delphijustin.biz\/wp-json\/wp\/v2\/posts\/571\/revisions"}],"predecessor-version":[{"id":576,"href":"https:\/\/delphijustin.biz\/wp-json\/wp\/v2\/posts\/571\/revisions\/576"}],"wp:attachment":[{"href":"https:\/\/delphijustin.biz\/wp-json\/wp\/v2\/media?parent=571"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/delphijustin.biz\/wp-json\/wp\/v2\/categories?post=571"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/delphijustin.biz\/wp-json\/wp\/v2\/tags?post=571"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}