I have made a small modal pop-up for getting the URL from the user. I want to insert that URL into a textbox in ReactJS. I can't figure out how to add that URL into the text area.
Use local state to achieve this. For example take url as input from user and set it into local state and use that state in modal.
Maybe this will help.
How can I get value from react modal bootstrap?
Get the value from the modal as mentioned above, store it, and then display that stored value in the textbox.
<textbox value= { nameOfVariable }></textbox>
Related
The variable data passed to a Bootstrap modal is hard coded in HTML data-text element field using "data-text" (according to the Bootstrap examples). If the modal's purpose is to allow a user to change that, then how do I send that back to the raw HTML data-text to update it for next time?
JS newbie here. I got Bootstrap 4 modals working and updating back to the server by Ajax (with a lot of Googling of StackOverFlow thanks!). I have about 100 text elements on the page which all load the same modal for editing of the clicked text field. The field initial value is hard coded into the page HTML in the data-text field (following the Bootstrap modal example). This allows passing of the current text value to pre-populate the modal field with the existing text value for editing.
Next, the user edits the note field in the modal and clicks submit. I am able to get the value and pass it back to the server, and update the DOM with the new edited value on the page, and everything works and looks great! So far so good.
Now here's the problem. Since I have not been able to figure out how to change the data-text field (which is hard coded in the page HTML), the screen (DOM) updates with the new value after submit correctly, but the data-text field of the element does not update. It is still the old value. It means the NEXT time I click to edit the text, the OLD value of the text field is pre-populated in the modal for editing.
Question: how do I update html data-text field by JS?
I have researched this problem at great length and without Stack Overflow I would never be able to get it working, so much appreciate you guys. Dozens of questions about passing variable TO Modals, but very few about passing the data back, and NONE about setting data-text on submit by JS.
text element definition example. This is a slightly simplified example. The text field contains some data from the server database, HTML is generated by PHP/MySQL. (1 out of 100 elements on page):
<td id="note_12345678" data-toggle="modal" data-target="#noteModal" data-note="<some text from db>" class="note"><same text from server db></td>
Here is the JS on submit code. Everything works except for the last line where I am trying to change the "data-note" field of the element:
function note_submit(element) {
var note = document.getElementById('message-text').value;
ajaxcall("/ajaxclick.php" , { note:note } , null); // Simplified, all is working.
noteElement = document.getElementById('note_12345678');
noteElement.innerText = note ; // Updates the DOM with submitted note.
noteElement.data-note = note ; // <== trying to change data-note here but obviously a syntax error.
}
Everything is working fine up to that last step. Clicking the text field opens modal, pre-loads the text for editing, allows the user to edit, click submit sends to server by Ajax for update, DOM note on screen is updated by JS. if I RELOAD the page, it loads the new edited text value from server db. Everything working great. Lots of joy.
Problem is NEXT time I click on the text element to edit it, the modal loads the OLD value from data-note hard coded into HTML. How to update it upon submit by JS? Thanks a million for any assistance. So close.
Updated: page is loading jquery-3.3.1.js, and bootstrap/4.0.0/js/bootstrap.min.js. Browser is FF V66.
I have this url
http://www.test.com/home-package/?location=locationA&bed=3&bath=4
and a variable (e.g. $location = "locationB") which holds the value user has selected when they land on the website. They can also change this location from any page they want and the variable will be updated with that location.
What I'm trying to achieve is,
If user is browsing http://www.test.com/home-package/?location=locationA&bed=3&bath=4 and then change the location to 'locationB', I want the url to update to http://www.test.com/home-package/?location=locationB
Hope I have made this clear.
Edit 1: User is selecting location from a dropdown list. <select> is wrapped inside <form> and upon hitting save, the value of location is saved in a session variable.
Thanks.
As I understand the locationB is in HTML input element? Add a onchange listener to the element and redirect user with javascript.
let locationB = getValueFromElement();
window.location.replace("http://www.test.com/home-package/?location="+locationB);
//or
window.location.href = "http://www.test.com/home-package/?location="+locationB;
Read differences between JS redirects.
If the locationB value comes from backend and redirecting in backend is not possible you can also add a hidden element that holds the value and read it with JS.
I have a web browser in XAML:
<phone:WebBrowser x:Name="Browser" Grid.Row="1" Grid.RowSpan="2"
Navigating="Browser_Navigating"/>
It displays HTML content present in isolated storage so I retrieve the content and store it in a string to display it on WebBrowser,
Browser.NavigateToString(str);
The string contains a button which acts as a link. I want to change the size of this button.I do not know how to access the button present in string which is stored inside Isolated storage. Any idea?
There are more than just one way to get this done.
It's about string-manipulation.
Example 1:
Search through the HTML-String for the ID or Name of the Button.
If you found it: simply add style="font-size:99px" into the Buttons Tag, where the 99 is the size of it. Change it how you like to.
Example 2:
If you know that the CSS (Styling) is in the same Website (String) then you can edit or add the font-size attribute there.
After you did this, just call your edited String like this:
Browser.NavigateToString(EditedString);
If you've got questions, ask ;)
page imageThis Images shows my page where i am facing a problem, i want my 'company' textbox get autocomplete by value fetched from database when i input a value in 'code'.
in a seperate page mysql queries will run to get company where code='*'
Both 'code' and 'company' are present in my databasedatabase image
Tried lots of techniques but failed to achieve anything.
Please help!!
Give us some code please.
You want to submit form and then, on new page - enter a value to new form with second textbox?
As you probably know - if you want to get data from database you must use classic SQL query in PHP file.
But - if you want do dynamicaly autocomplete second textbox without submit - you can use jQuery:
$('#your_textbox').on('input', function() {
/* This will be fired every time, when textbox's value changes. */
$('#your_second_textbox').val($('#yout_textbox').val(''));
} );
the explanation given here http://wiki.asp.net/404.aspx?aspxerrorpath=/themes/fan/pages/page.aspx/282/passing-value-from-popup-window-to-parent-form39s-textbox/
is exactly what I want , but Its not giving the output and parent page despite doing exactly as explained ,
can anyone please send sample website with northwind data base ? no need of mdf file ,just a tested demo I will attach Northwind .
The task s simple , In pop up window there is a grid with some databound column and one with button , my task is when buton is clicked it must return text from respective grd row to the parent page'control (any)
Maybe is not working to you because on the sample is hard code the button id, and this logically because on the popup window did not know how the button have been render.
getElementById("ctl00_ContentPlaceHolder1_TextBox2")
So ether correct this id to make it as its appear to your page, ether make the control id on TextBox2 static so is not change, and get it by name.