Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > RocketCake
PHP Text Form Field - Change Value

emvie468
Registered User
Quote
2020-10-08 23:01:31

I have a text edit field on my webform (using php) that I need to change its 'Value', so that on submission, if there is an error, all the fields with the correct information retain that information and only the error fields need changing. Per online tutorials, I think I need to change the 'Value' attribute of my text edit box on the webform.

Currenty, the text edit field code looks like this:

<input type="text" value="" title="" name="formEmail" maxlength="50" id="edit_7a791d4e" >

There is a 'Value' option for the text edit field, in the 'Properties' pane of the RocketCake editor. When entering the value I want to see in the code of the text edit field, in the Properties pane (Value), the code of the text edit field looks good (ie: its 'Value' reads how I want)

<input type="text" value="<?=var$Email;?>" title="" name="formEmail" maxlength="50" id="edit_7a791d4e" >

but the code doesn't change the behaviour of the form AND the code entered to change the 'Value' is displayed in the text edit box. Naturally I don't want this!!

So my question is, how do I change the Value part of the code, of the text edit box in my webform.

Here is the complete code to the form (without changing the value input):

<form action="myformtest.php"
enctype="application/x-www-form-urlencoded"
method="POST" id="form_2d8b2532"
>
<div id="form_2d8b2532_padding" >
<div class="textstyle1">
<span class="textstyle2">*Required fields</span>
<span class="textstyle3"><br/><br/><br/></span>
<span class="textstyle3">Email address: </span>
<input type="text" value="" title="" name="formEmail" maxlength="50" id="edit_7a791d4e"
>
<span class="textstyle3"><br/>(Please ensure the email address is correct or we will not be able to respond to you</span>
<span class="textstyle3">)</span>
<span class="textstyle3"> <br/></span>
<span class="textstyle3"><br/> <br/>Name of Renter </span>
<input type="text" value="" title="" name="formName" id="edit_26871aa4"
>
<span class="textstyle3"><br/>First & Last)<br/><br/><br/><br/><br/><br/><br/><br/></span>
</div>
<div class="textstyle4">
<input name="formSubmit" type="submit" value="Submit" title="" id="button_25956e11" >
</div>
<div class="textstyle1">
<span class="textstyle3"><br/><br/></span>
</div>
<div style="clear:both"></div>
</div>
</form>


erik
Registered User
Quote
2020-10-09 07:32:33

You can only change the value of that field in your PHP code, if that code also generates that field, which is not the case here. That's a bummer.

BUT, there is a workaround:

If your PHP decides that it want to change the value, it can emit some JavaScript code, which then sets the value of that field on the users client. PHP Code for writing out a JavaScript which sets the "formName" field to "somevalue" would look like this:


echo("<script>document.getElementById('edit_26871aa4').value = 'somevalue';</script>");



emvie468
Registered User
Quote
2020-10-12 18:21:49

Erik:

Thank you for the response. I was able to change the Properties Value to:

<?php echo $email;?>

by typing that string in Value in the Properties pane. This works to retain the Email value in the form field if the form returns other errors, but the Email entered is correct.

I'm still working on the form and will post another question.

Many thanks


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "In?ernational" (you are not logged in)


Text:

 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


   






Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact