Hi,
Here am trying to populate the page with new url, with the value that is being entered in the text box.
this is the php code called example.php -
<?
-
echo "<input type='text' name='text1' id='text1' />\n";
-
echo "<input type='button' name='button' onclick=\"return reload_page_with_value()\" />\n";
-
?>
-
the javascript code: -
function reload_page_with_value() {
-
var value=document.GetElementById('text1').value;
-
var url="example.php";
-
url=url+"?value=+"value;
-
window.location=url;
-
}
-
The problem here is, after the page is being reloaded with the value, the text entered in the textbox will not be available. Can somebody tell me the reason why this is happening and give the solution??
thanks
13 4611 @sarega
getElementById() is written with a small "g", but why so complicated? just echo out the value in your server script using the default value attribute for <input> (<input ... value="default"/>). when you have a form, you don't need to reload the page with location.href, that's what the submit button is for (except for some special cases maybe).
I want that value to be used for further processing. So how do i retrieve the value of value??
Javascript processing or PHP processing?
I have to do php processing
submit the form. depending upon which submit button you use (you can have more than one submit type button in a form), the script can do different tasks with it.
Actually the form is not complete with this textbox, there are more checkboxes in the form. After that i have a submit button
that doesn't matter, if you name this submit button (not the final one), say, "refresh" you can test for this value in the script and print the page with all the currently submitted values (and maybe some according processing))
like: - if (isset($_POST['refresh']))
-
{
-
// do some refreshing
-
// compute some other stuff
-
}
I did not understand how to proceed?
Cant we use textbox and checkboxes for window.location property??
Returns a Location object, which contains information about the URL of the document and provides methods for changing that URL. You can also assign to this property to load another URL.
window.location seems not the right place to me to handle form elements..... unless I've totally misunderstood you
@sarega
you can have multiple submit buttons in a form, so you can assign in your script a different function/processing to each of the buttons. the buttons can be distinguished by their name attributes. so if you put one submit button named "process" (just for example) and another one "refresh", then you can write (there's always only one submit button's value sent): - // HTML
-
<form action="...php" method="post" ...>
-
<!-- your form elements go here -->
-
<input type="submit" name="refresh" value="preview"/>
-
<input type="submit" name="process" value="send"/>
-
</form>
-
-
// PHP
-
if (isset($_POST['refresh']))
-
{
-
// preview and its processing code comes here
-
}
-
if (isset($_POST['process']))
-
{
-
// final processing code comes here
-
}
form elements which were not filled are either not present in $_POST or have an empty value (which you can check for with empty())
There exists already another form which is pointing to another php file, in this case can i still use another form which points to a diff php file?
maybe a demonstrative html sample can clarify the matter for me.... I'm a bit lost now.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: J P Singh |
last post by:
Hi Guys
Wonder if someone can help me with this.
I have a form where a user clicks a button which gives them a pop up windows
to allow them to add the data. The user adds the data and click...
|
by: alanstew |
last post by:
With the body tag calling out 'window onload', a function with a
'window.open' fails at the 'window.open' line. If I cut out the body
tag, the function executes as normal.
At first I thought it...
|
by: Richard |
last post by:
I have a requirement to put a GDI style circle or rectangle border around
the selected row of a datagrid/ It will overlap into the row above and below
the selected row. Doing this in a the OnPaint...
|
by: johnsonholding |
last post by:
Here is the code for a pop-up window that works in Firefox and not in
IE - I get a java error or something,
Here is the code :
</script>
<SCRIPT language="JavaScript"...
|
by: monomaniac21 |
last post by:
Hi I know this isnt really a php question but can anyone tell me how
you parse post variables to a popup window, here's my code so far, im
trying to pass the value entered into a radio button:
...
|
by: anthonybrough |
last post by:
I have an asp page that has a form to collect user data in a form.
when the user clicks submit the input is validated. If any fields are
not acceptable the user clicks on a button to go back to...
|
by: George Lft |
last post by:
ok, first of all, i built my register page using dreamweaver tool which the codes haven been out of control. Now i'm thinking that turning over everything - by using this another set of codes. And...
|
by: geetamadhavi |
last post by:
Hi All,
I have developed a php applciaiton where a new window is opening on checking the whether valid user orntot how to make that in same window after checking i have die(' not valid user ' ); i...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |