0

i need help in correcting this string.

I am trying:

$returnStr = 'Condition<select name="lstCondition" onchange="javascript:addDateTextbox(this.value,' . ' " ' . $colName . ' ", ' . $key . ')">'; 

I want this:

<select name="lstCondition" onchange="javascript:addDateTextbox(this.value, 'dateTime', 42)>

I am getting this:

 <select name="lstCondition" onchange="javascript:addDateTextbox(this.value, " dateTime ", 42)>

3 Answers 3

2

In your statement

name="lstCondition" onchange="javascript:addDateTextbox(this.value,' . ' " ' . $colName  . ' ", ' . $key . ')">';

you have spaces each side of the ' marks hence you're getting the spaces round the colname. If you change it to

name="lstCondition" onchange="javascript:addDateTextbox(this.value,' . '\'' . $colName  . '\', ' . $key . ')">';

you should get the result you wanted. I have escaped the '

Sign up to request clarification or add additional context in comments.

Comments

2
$returnStr = 'Condition<select name="lstCondition" 
              onchange="javascript:addDateTextbox 
             (this.value,' . ' \'' . $colName . ' \',' . $key . ')">';

Comments

0

try the below code

 <?php 
$returnStr = '<select name="lstCondition" onchange="javascript:addDateTextbox(this.value, \'dateTime\', 42)"><option>Select</option></select>';
echo $returnStr;
?>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.