getElementBy to get Value JS - javascript

Can someone help pull the value with "3355"?
<form action="http://www.ebest.cl/checkout/cart/add/uenc/aHR0cDovL3d3dy5lYmVzdC5jbC9hdWRpZm9ub3MtYWx0YS1maWRlbGlkYWQtaG91c2Utb2YtbWFybGV5LXJldm9sdXRpb24uaHRtbD9fX19TSUQ9VQ,,/product/3355/form_key/c2b66ca036853b1a/" method="post" id="product_addtocart_form">
<input name="form_key" type="hidden" value="c2b66ca036853b1a" />
<div class="no-display">
<input type="hidden" name="product" value="3355" />
<input type="hidden" name="related_product" id="related-products-field" value="" />
</div>
Which getElementBy function would I use?
Thanks.

document.querySelector(".no-display > input[name=product]").value;
or more specific:
document.querySelector("#product_addtocart_form .no-display > input[name=product]").value;

Related

How to link webform to Bronto Database list

I have an old Html form already hooked up to Bronto already:
<div id="mc_embed_signup"><form id="lunar-form"><input name="fid" type="hidden" value="3yuzy87x8gjdf73zq9p6lav86dfdw" />
<input name="sid" type="hidden" value="01c3cd9e15ec122d6bada9aeba8dbe44" />
<input name="delid" type="hidden" value="" />
<input name="subid" type="hidden" value="" />
<input name="td" type="hidden" value="" />
<input name="formtype" type="hidden" value="addcontact" />
<input id="field_361909" class="hidden field" name="67765[361909]" type="hidden" value="Weekly" />
<input id="field_361796" class="hidden field" name="67746[361796]" type="hidden" value="Hair Shaman Lunar" />
<script type="text/javascript">
var fieldMaps = {};
</script>
<fieldset id="popupfieldset">
<div class="mc-field-group-email">
<input id="mce-EMAIL" class="text field fb-email" title="7 characters minimum" autocomplete="off" name="74662" pattern=".{7,}" required="" type="email" value="" placeholder="Email" />
i want to add another input for first name, how do I make sure it connects to the bronto database correctly?

How do I align a search bar and search button in HTML?

I would like to align search button next to search bar but I don't know how to do it.
HTML :
<div id="tmsearch">
<span class="btn-toogle active"></span>
<form id="tmsearchbox" method="get">
<input type="hidden" name="controller" value="search"/>
<input type="hidden" name="orderby" value="position"/>
<input type="hidden" name="orderway" value="desc"/>
<input class="tm_search_query form-control" type="text" id="tm_search_query" name="search_query" placeholder="What are you shopping for today ?"/>
</form>
<button>Search</button>
</div>
JSFIDDLE ==> https://jsfiddle.net/bpr6qmjt/3/
Thanks
Use CSS style "display:inline"
<div id="tmsearch">
<span class="btn-toogle active"></span>
<form id="tmsearchbox" method="get" style="display:inline">
<input type="hidden" name="controller" value="search"/>
<input type="hidden" name="orderby" value="position"/>
<input type="hidden" name="orderway" value="desc"/>
<input class="tm_search_query form-control" type="text" id="tm_search_query" name="search_query" placeholder="What are you shopping for today ?"/>
</form>
<button style="display:inline">Search</button>
</div>
You can easy add style display:inline-block to the form element.
like this
<form id="tmsearchbox" method="get" style="display:inline-block">
or you can add it by id
form#tmsearchbox { display :inline-block }
You could set the style of the form in CSS:
#tmsearchbox {display:inline;}
Or embedded the style in the form tag:
<form id="tmsearchbox" method="get" style="display:inline;">
<form id="tmsearchbox" method="get">
<input type="hidden" name="controller" value="search">
<input type="hidden" name="orderby" value="position">
<input type="hidden" name="orderway" value="desc">
<input class="tm_search_query form-control" id="myinput" type="text" name="search_query" placeholder="What are you shopping for today ?" style="
float: left;
">
</form>

send array via onsubmit form

I have a html form like this :
<form name="form" id="form" method="get" action="www.example.com" enctype="multipart/form-data" onsubmit="window.location.href = 'www.example.com/goods:' + document.getElementsByClassName('goods').serialize; return false;" autocomplete="off">
<input name="goods" type="text" id="<?=$goods['id']?>" class="goods" value="" />
<input name="goods" type="text" id="<?=$goods['id']?>" class="goods" value="" />
<input name="goods" type="text" id="<?=$goods['id']?>" class="goods" value="" />
<input name="goods" type="text" id="<?=$goods['id']?>" class="goods" value="" />
<input name="goods" type="text" id="<?=$goods['id']?>" class="goods" value="" />
<input name="submit" type="submit" class="submit" value="submit" />
</form>
I am trying to pass via onsubmit form an array with the values of the input fields and then redirect to the above url but i cant manage to do it. Is there any way to achieve it?
To define an array in HTML forms you can use [], like this:
<input name="goods[]"/>
I think you are trying to code like this. take name as array
<form name="form" id="form" method="get" action="www.example.com" enctype="multipart/form-data" onsubmit="window.location.href = 'www.example.com/goods:' + document.getElementsByClassName('goods').serialize; return false;" autocomplete="off">
<?php foreach ($goods as $key => $good) { ?>
<input name="goods[]" type="text" id="<?php echo $good['id']; ?>" class="goods" value="" />
<?php } ?>
<input name="submit" type="submit" class="submit" value="submit" />
</form>

minicart.js not working, cart is not popping up

I am using Minicart.JS for my simple paypal shopping cart. But this is not working as it should. The cart is not popping up if I click 'add to cart' button.
Here's my code.
<html>
<body>
<script src="//cdnjs.cloudflare.com/ajax/libs/minicart/3.0.3/minicart.min.js"></script>
<script>
paypal.minicart.render();
</script>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_cart" />
<input type="hidden" name="add" value="1" />
<input type="hidden" name="business" value="labs-feedback-minicart#paypal.com" />
<input type="hidden" name="item_name" value="Test Product" />
<input type="hidden" name="quantity" value="1" />
<input type="hidden" name="amount" value="1.00" />
<input type="hidden" name="currency_code" value="USD" />
<input type="hidden" name="no_shipping" value="2">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="shipping2" value="1.50">
<input type="hidden" name="shipping" value="2.50">
<strong>Test Product</strong>
<p>
<label><input type="checkbox" id="terms" name="terms" value="" /> I agree to the terms</label>
</p>
<input type="submit" name="submit" value="Add to cart" />
</form>
<script>
paypal.minicart.render();
paypal.minicart.cart.on('checkout', function (evt) {
var hasAgreed = !!document.getElementById('terms').checked;
if (!hasAgreed) {
alert('You must agree to the terms!');
evt.preventDefault();
}
});
</script>
</body>
</html>
Here is the actual site. , I found an error in console that said:
Uncaught TypeError: Cannot call method 'appendChild' of null
I am not sure how to fix this, please let me know what's wrong with my setup. Thanks.
You need to change the Add to cart button to not be saved on PayPal (In Profit and loss Section) and also unprotect code after the button is created right before you copy and paste it :)
Hope this helps :)

get id from radio input by clicking a link (siblings?)

so i have a list of addresses each with edit links and i want to grab the ID of the input within the list item
<li class="last">
<div class="checkout-select-address"><input type="radio" name="checkout_selected_address" id="checkout_selected_address_3" value="" /></div>
<div class="checkout-select-address-details">
<p><label for="checkout_selected_address_3">(Mothers)</label> Edit Address</p>
<input type="hidden" id="checkout_selected_address_3_name" value="" />
<input type="hidden" id="checkout_selected_address_3_title" value="" />
<input type="hidden" id="checkout_selected_address_3_first_name" value="" />
<input type="hidden" id="checkout_selected_address_3_last_name" value="" />
<input type="hidden" id="checkout_selected_address_3_address_line_1" value="" />
<input type="hidden" id="checkout_selected_address_3_address_line_2" value="" />
<input type="hidden" id="checkout_selected_address_3_address_line_3" value="" />
<input type="hidden" id="checkout_selected_address_3_town_city" value="" />
<input type="hidden" id="checkout_selected_address_3_county" value="" />
<input type="hidden" id="checkout_selected_address_3_postcode" value="" />
<input type="hidden" id="checkout_selected_address_3_country" value="" />
</div>
<div class="clear"></div>
so clicking on the link with class "edit-link" it will get the ID for the radio input within the li
Thanks in advance
try this :
$(".edit-link").click(function(){
alert($(this).closest("li").find("input[type=radio]").attr("id"));
});
demo : http://jsfiddle.net/ZABBS/

Categories

Resources