Can't type in textarea [duplicate] - html

I need help. My form in my page looks like below however when I click on the text box the cursor won't appear and I can't type
<form name="input" action="postblog.php?name=<?PHP echo ($_GET['name']); ?>" method="post">
Post: <input type="text" name="text2">
<input type="submit" value="Submit">
</form>

There's probably an error that's not being displayed on your screen because it's appearing inside the HTML tags. Make sure to check if $_GET['name'] is set first:
<form name="input" action="postblog.php?name=<?php echo ($_GET && isset($_GET['name'])) ? $_GET['name'] : 'No_Name_Value_From_GET'; ?>" method="post">
Post: <input type="text" name="text2" />
<input type="submit" value="Submit" />
</form>
In this instance, if $_GET['name'] is not set, the value for ?name= will be No_Name_Value_From_GET (but you can change it to whatever you want).
HTH... :)

Related

How to use value from input tag in the same form

I am looking how to reuse the value="typed_from_user" into another tag in the same formulary without using js, just PHP & HTML.
Is it even possible?
For example, here i want to reuse the word 'pizza'
<form>
<input name="hello" type="text" value="I want pizza">
<input name="order" type="text" value="pizza">
</form>
maybe something storing it in a variable?
<form>
<input name="hello" type="text" value="<?php echo $whatyouwant ;?>">
<input name="lunch" type="text" value="<?php echo substr($whatyouwant,7,5);?>"><!--cut it from letter 7, the word pizza-->
<input name="order" type="submit" value="submit">
</form>
yeah, supouse that we know where exactly starts the word pizza
This are the files i am using as tests
action.php
form.php
<?php
//action.php
$var = $_POST['hello'];
$var_lunch= $_POST['lunch'];
echo "hello: $var<br>";
echo "lunch: $var_lunch<br>";
?>
file form.php:
<html>
<header>
<title>test-page</title>
<!--bootstrap-->
<link rel="stylesheet" type="text/css" href="../../../css/bootstrap/bootstrap_v4.0.0.css">
</header>
<body>
<?php
$whatyouwant=777;
?>
<form method="post" action="action.php">
<input name="hello" type="text" value="<?php echo $whatyouwant ;?>">
<input name="lunch" type="text" value="<?php echo substr($whatyouwant,7,5);?>">
<input name="order" type="submit" value="submit">
</form>
</body>
</html>
OUTPUT:
hello: i want pizza
lunch:
If you are trying to get the input value form one text field to another text field only using PhP and HTML, I have to say that it is quite impossible. PhP is the server side language so to get the value from one field to another, it must first reach the server and then it display but will show error in PhP.
To achieve this, you have to use JS. You can achieve this from just a few lines of code using jQuery.

how put put dynamically populated number into input value field

I have dynamically populated value coming from an external js file. The value is working just fine when I call it in the HTML page but I'm stuck on how to have an input field display this value.
Here is my HTML:
<form action="../mail.php" method="POST" class="location-form">
<div class="device-details">
<h2>Device: iPhone5</h2>
<h2>Repair Cost: <span id="result">0</span></h2>
</div>
<input name="device" type="hidden" id="device" value="iPhone5" maxlength="20">
<input name="cost" type="hidden" id="cost" value="" maxlength="20">
<div class="submit-btn">
<input type="submit" value="Submit Request" />
</div>
</form>
<script>
document.getElementById("result").innerHTML = localStorage.getItem("sum");
</script>
at the top, in the div "device-details", the h2 "repair cost" is populating the value just fine, no issues. But I cannot seem to populate the last input with this value.
<input name="cost" type="hidden" id="cost" value="(need the value here)" maxlength="20">
I need the value of the input field to mimic the value of the repair cost at the top in order to send that value to an email address.
I've tried inserting the following into the value and it didn't work
value="<span id='result'>0</span>"
I've tried creating a variable in php and then putting the variable into the value field, and it did not work
<?php
$my_var = '<span id="result">0</span>';
?>
value="<?php echo '$my_var'); ?>"
I've also tried:
value="<?php echo htmlspecialchars($my_var); ?>"
these last two just returned the actual HTML code
<span id="result"></span>
instead of the populated value.
Try this one.
<!DOCTYPE html>
<html>
<body onload="abc()">
<form action="../mail.php" method="POST" class="location-form">
<div class="device-details">
<h2>Device: iPhone5</h2>
<h2>Repair Cost: <span id="result">0</span></h2>
</div>
<input name="device" type="hidden" id="device" value="iPhone5" maxlength="20">
<input name="cost" type="hidden" id="cost" value="" maxlength="20">
<div class="submit-btn">
<input type="submit" value="Submit Request" />
</div>
</form>
<script>
function abc(){
document.getElementById("result").innerHTML=localStorage.getItem("sum");
document.getElementById("cost").value = localStorage.getItem("sum");
}
</script>
</body>
</html>

HTML form name replaced with wrong symbols

I have the following form
<form name="input" action="http://testdomain.com/search/?" method="get" autocomplete="off">
<input type="text" name="?wpv_paged_preload_reach=1&wpv_view_count=1&wpv_post_id=205499&wpv_post_search=">
<input type="submit" id="searchsubmit" value="">
</form>
However the actual URL displays the following search query:
/search/?%3Fwpv_paged_preload_reach%3D1%26wpv_view_count%3D1%26wpv_post_id%3D205499%26wpv_post_search%3D=test
It seems that special symbols such as ? and = are getting replaced with special Encoding characters.
My question is, how do I get the form to not switch my special symbols with the encoding characters?
Thanks
The name of an input element controls the name of one field. The browser doesn’t blindly mash it and its value together and send that to the server. For a GET request, you can include each one as a hidden field:
<form name="input" action="http://testdomain.com/search/" method="get" autocomplete="off">
<input type="hidden" name="wpv_paged_preload_reach" value="1" />
<input type="hidden" name="wpv_view_count" value="1" />
<input type="hidden" name="wpv_post_id" value="205499" />
<input type="text" name="wpv_post_search" />
<input type="submit" id="searchsubmit" />
</form>

Text - Empty Text Node issue in IE 8

I am using IE8 browser. It creates an empty text node after <input /><span><textarea> like this tags.
I cant found how rectify this. Can anybody tell me to fix this issue..?
Code :-
<form id="addNewsForm" action="/addNews.php" method="post" enctype="multipart/form-data">
<label>Title : </label>
<input type="text" class="addNewsTitle" name="addNewsTitle" />
<label>Content : </label>
<textarea rows="10" cols="35" name="addNewsCnt" class="addNewsCnt"></textarea>
<label>Category : </label>
<select>
<option>world</option>
<option>important</option>
<option>common</option>
<option>tamilnadu</option>
<option>lifestyle</option>
</select>
<input type="button" name="noimage" class="newsImgAdd" value="ADD IMAGE" />
<input type="file" name="file" class="addNewsImg" />
<input type="submit" class="submit addNewsSubmit" value="SUBMIT" />
<iframe id="addNewsFrame" name="addNewsFrame"></iframe>
</form>
IE8 shows the empty text nodes because sometimes it considers the space between two elements as Empty Text Node.
You need to remove the space between the fields.
Fiddle - http://jsfiddle.net/uTDWD/1/

Two "form action's" on one line

I have just finished putting a login and register bit on my website and now I'm just cleaning things up, but then I came to this problem I have two form action's on one page, each one goes to a different page, easy enough, but I can't seem to get them both on one line.
Here is the code for the form actions:
<form action='logout.php' method='POST'>
<input type='submit' value='Logout' />
</form>
<form action='changepassword.php' method='POST'>
<input type='submit' value='Change password' />
</form>
I've tried
<form action='logout.php' method='POST'>
<input type='submit' value='Logout' />
<form action='changepassword.php' method='POST'>
<input type='submit' value='Change password' />
</form>
but both buttons go to the same location
the website is www.crossception.com, you will need to login to get to this problem
I've already made a login and password for every one to use
username : stackoverflow
password : test101
thank you very much
connor
(aged 15)
<span style="float:left;">
<form action='logout.php' method='POST'>
<input type='submit' value='Logout' />
</form>
</span>
<span style="float:right;">
<form action='changepassword.php' method='POST'>
<input type='submit' value='Change password' />
</form>
</span>
If I understand your question properly, I think you need to use some CSS:
form {
float: left;
width: auto;
}
You might want to add a class to those forms to stop yourself styling all forms like this
Here's the dirty inline version
<form action='logout.php' method='POST' style='float:left;'>
<input type='submit' value='Logout' />
</form>
<form action='changepassword.php' method='POST'>
<input type='submit' value='Change password' />
</form>
Of course James's suggestion to use a class is the proper way to do it.
Btw, those forms should be after the opening body tag.