Given HTML:
<form id="profileSetupForm26" action="?x=5Y-M5vRfdujC7zuC5S4Ih-iKzt7c666WKAuQI9XKA0HTB5pnCbGea8k57gawfMKixyxBeUZxK3nyBO6UhTEYuLPttld6WIF94AhgIV8Jlsr8MK9lr-IKLg" method="post" ric:loaded="true">
<div style="width:0px;height:0px;position:absolute;left:-100px;top:-100px;overflow:hidden">
<input id="profileSetupForm26_hf_0" type="hidden" name="profileSetupForm26_hf_0">
I used below code but it did not worked can you please help me ?, because above form id is changing dynamically.
Code:
this.fillXPath('form#profileSetupForm', {
'//input[#name="Form"]': 'Hi',}
You cannot use regexp in CSS selector, but you can match the begining of an attribute:
$("form[id^='profileSetupForm']")
will match profileSetupForm26, profileSetupForm27, profileSetupFormWhatEver, ...
Related
This works :
<input
id="chk-products"
name="chk-products"
type="checkbox"
x-on:click="showProducts = document.getElementById('chk-products').checked">
But this doesn't :
<input
id="chk-products"
name="chk-products"
type="checkbox"
x-on:click="showProducts = this.checked">
I was wondering why this isn't available in alpinejs's directives ?
With Alpine.js you don't have to inspect/mutate the DOM manually. It uses the data model: first you define some data, then you bind it to some input elements and let Alpine.js handle the DOM mutations, etc.
<script defer src="https://unpkg.com/alpinejs#3.x.x/dist/cdn.min.js"></script>
<div x-data="{showProducts: false}">
<input type="checkbox" x-model="showProducts" /> Show products
<div x-show="showProducts">Products are shown.</div>
<div x-show="!showProducts">Products are hidden.</div>
</div>
The this keyword is available inside a component created with Alpine.data() global function.
The x-on:click directive in Alpine.js is designed to execute a JavaScript expression when an element is clicked. In this case, the expression is trying to access the checked state of the checkbox element, which can be done more directly by using the this keyword to access the element that the directive is applied to. Unfortunately, Alpine.js does not support the use of the this keyword in its directives.
hi i want to change this url from get form
http://127.0.0.1:8000/allfiles?category_id=1&file_id=1
to this in laravel
http://127.0.0.1:8000/allfiles?filter[category_id]=1&filter[file_id]=1
how can i do that?
Actually i want change perquery=? to filter[perquery]=?
thanks
Try something like this in the blade (you can modify it if need):
<form action="http://127.0.0.1:8000/allfiles" method="GET">
<input name="filter['category_id']">
<input name="filter['file_id']">
<input type="submit">
</form>
i have a dynamic form that is generated from a json
and my ngRepeat looks like this:
<div ng-repeat="(q, w) in user.education">
<div class="form-group">
<label for="{{q}}">{{q}}</label>
<input type="text" class="form-control" name="{{q}}" ng-model="user.education.{{q}}">
</div>
</div>
so the problem is that the {{q}} in the ng-model isnt showing the data... but in the label and input name it is working...any ideas why? because i will need to continue using these variables..i know that the brackets are not neccesary because of the ng. but whenb i loose the brackets...then the 'q' character is shown..
I believe you can just change this:
ng-model="user.education.{{q}}"
to this:
ng-model="user.education[q]"
So referencing your variable q property in the user.education object via bracket notation rather than dot notation.
when i give an input field value as blackhat%%1985 and submit i get the post value as blackhat%85
the value is changed after require_once BASEPATH.'core/CodeIgniter.php';
<form action="" method="post" id="submitForm">
<input type="hidden" name="a" value="blackhat%%1985" />
<input type="submit" name="b" />
</form>
use urlencode() function for this.
You can use JavaScript's encodeURIComponent to encode the value before submitting the form.
encodeURIComponent('blackhat%%1985');
Of course, don't forget to decode it on the server-side after that.
HTML
<form method="GET">
<input type="text" name="txt"/>
<input type="button" onclick="get()"/>
</form>
returns
Javascript
returns
function get(){
var ik=$('#txt').value();
$.get('action.php',{text:ik});
}
PHP
<?php $text=$_GET['txt']; print $text?>
When I look at firebug I get a notice saying that index txt is
undefined, I tried everything but it's not working. What am I doing
wrong?
$('#txt') will search for an element with id=txt and you don't have any element with id "txt" on your HTML code.
To get a value of the field you should use the .val() method.
The code that should work for you is:
$('input[name="txt"]').val();
Or define an id to your field and your code should be like this:
$('#txt').val();
In your PHP code your are looking for a variable called "txt" and in your Javascript code you are defining "text" as your variable so... you should read the $_GET['text'];
[]'s
Igor.
Where is your #txt element?
Try
<form method="GET">
<input type="text" id="txt" name="txt"/>
<input type="button" onclick="get()"/>
</form>
You are passing {text:ik}, so in your action.php you should get the value you want from $_GET['text'] not $_GET['txt']
Ok, so there are three problems going on.
First, you probably want id=txt in the HTML. You currently have name=txt. The #txt is going to retrieve the ID attribute in the HTML (not the Name attribute).
Here, use this for the HTML:
<form method="GET">
<!-- You need to have an ID value, if you are using #txt in jQuery -->
<!-- I assign both ID and Name to the same value -->
<input type="text" id="txt" name="txt"/>
<input type="button" onclick="get()"/>
</form>
Second, your call to action.php is passing the key "text", not "txt", and third you need to use val().
This might work for the JavaScript:
function get(){
// The #txt is getting an ID value
// You also need to use val() instead of value() ... according to #Igor
var ik=$('#txt').val();
// If PHP is looking for a txt key, you'll want that here as well
// The key could by "mykey" as long as PHP expects "mykey".
$.get('action.php',{txt:ik});
}
So, you'll want to correct both those errors.
The PHP looks fine.
Use the val() method instead off value();
HTML
<input type="button" id="go"/>
Script
$(function(){
var ik=$(input'[name=txt]').val();
$.get('action.php',{txt : ik},function(data){
//do whatever with the response from get call
});
});